Skip to content

如何将老项目从cocos2dx转到cocos creator

step1 ccbi转换为ccb

如果有ccbi文件那么恭喜你,你省去很多时间处理界面的问题 在很多老得cocos2dx的项目中使用的都是cocosbuilder创建的ccbi,但是到了cocos creator不再支持了

首先使用ccb转ccbi的工具 把ccbi文件拷贝到工具所在目录,最好保持原始目录结构,工具自动遍历所有目录下的ccbi文件进行转换

ccbi转换工具下载

step2 导入到cocos creator中

导入到cocos creator中,示意图

cocos creator导入ccb示意图

如果没有你没有.ccbproj,创建一个,格式如下面的文件

xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>deviceOrientationLandscapeLeft</key>
        <true/>
        <key>deviceOrientationLandscapeRight</key>
        <true/>
        <key>deviceOrientationPortrait</key>
        <false/>
        <key>deviceOrientationUpsideDown</key>
        <false/>
        <key>exporter</key>
        <string>ccbi</string>
        <key>fileType</key>
        <string>CocosBuilderProject</string>
        <key>fileVersion</key>
        <integer>1</integer>
        <key>flattenPaths</key>
        <false/>
        <key>generatedSpriteSheets</key>
        <dict/>
        <key>javascriptBased</key>
        <false/>
        <key>javascriptMainCCB</key>
        <string></string>
        <key>needRepublish</key>
        <false/>
        <key>onlyPublishCCBs</key>
        <true/>
        <key>publishDirectory</key>
        <string>Published-iOS</string>
        <key>publishDirectoryAndroid</key>
        <string>Published-Android</string>
        <key>publishDirectoryHTML5</key>
        <string>Published-HTML5</string>
        <key>publishEnabledAndroid</key>
        <false/>
        <key>publishEnabledHTML5</key>
        <false/>
        <key>publishEnablediPhone</key>
        <true/>
        <key>publishResolutionHTML5_height</key>
        <integer>320</integer>
        <key>publishResolutionHTML5_scale</key>
        <integer>1</integer>
        <key>publishResolutionHTML5_width</key>
        <integer>480</integer>
        <key>publishResolution_</key>
        <true/>
        <key>publishResolution_hd</key>
        <false/>
        <key>publishResolution_ipad</key>
        <false/>
        <key>publishResolution_ipadhd</key>
        <true/>
        <key>publishResolution_large</key>
        <true/>
        <key>publishResolution_medium</key>
        <true/>
        <key>publishResolution_small</key>
        <true/>
        <key>publishResolution_xlarge</key>
        <true/>
        <key>publishResolution_xsmall</key>
        <true/>
        <key>publishToZipFile</key>
        <false/>
        <key>resourceAutoScaleFactor</key>
        <integer>4</integer>
        <key>resourcePaths</key>
        <array>
            <dict>
                <key>path</key>
                <string>Resources</string>
            </dict>
            <dict>
                <key>path</key>
                <string>../srcres/ui</string>
            </dict>
            <dict>
                <key>path</key>
                <string>../srcres/fonts</string>
            </dict>
        </array>
    </dict>
</plist>

特别注意一下几个path,path是之前的ccbi引用到的资源的路径,这些资源你也需要拷贝到相应的目录 拷贝之后保持目录结构不变,这样你的ccbi转换之后还能正常引用原来的图片,否则就会丢失

PS:.pvr.ccz这种格式的图集引入到cocos creator会有问题,请自行手动处理,如果实在不会可以邮件我