加载SpriteBuilder中的scene为何不能带后缀

简介:

我们在Xcode中切换SpriteBuilder中的scene时,一般使用的是如下代码:

-(void)exitButtonPressed:(CCControl*)sender{
    CCLOG(@"Get me outa here!");
    CCLOG(@"sender is %@",sender);

    CCScene *scene = [CCBReader loadAsScene:@"MainScene"];

    CCTransition *transition = [CCTransition transitionCrossFadeWithDuration:1.5];
    [[CCDirector sharedDirector]presentScene:scene withTransition:transition];
}

但是实际我们知道MainScene是放在SpriteBuilder中的MainScen.ccb文件中的,我们能否在代码中加后缀调用呢?答案是:不可以!

原文引用如下:

“You should not append the .ccb file extension when loading CCBs. It’s a common and understandable mistake, but CCBReader will fail to load files where you specify the .ccb extension. Published CCB files are converted to a binary format optimized for fast loading and compact storage. This binary file format carries the extension .ccbi—that’s .ccb with a trailing i. The plain text format .ccb files aren’t actually in the bundle. Therefore, it’s important to omit the file extension in calls to CCBReader. Or, perhaps to remind you of the differing extensions, you can also append the .ccbi extension.”

原来SpriteBuilder中的ccb文件为了空间和格式的需求实际被转换为ccbi文件放在bundle中,这就是原因.

但是我们可以明确加载后缀为ccbi的文件,这样是可以的:

//that's all right!!!
CCScene *scene = [CCBReader loadAsScene:@"MainScene.ccbi"];
相关文章
PyQt5 技术篇-调用文件对话框获取文件、文件夹路径。文件对话框返回选中的多个文件路径
PyQt5 技术篇-调用文件对话框获取文件、文件夹路径。文件对话框返回选中的多个文件路径
2354 0
PyQt5 技术篇-调用文件对话框获取文件、文件夹路径。文件对话框返回选中的多个文件路径
PyQt5 图形界面 - Qt Designer创建qrc资源文件引用图片资源实例演示,QTextBrower组件引用图片资源方法展示
PyQt5 图形界面 - Qt Designer创建qrc资源文件引用图片资源实例演示,QTextBrower组件引用图片资源方法展示
345 0
PyQt5 图形界面 - Qt Designer创建qrc资源文件引用图片资源实例演示,QTextBrower组件引用图片资源方法展示
EMF介绍系列(六、自定义命令)
EMF生成的应用程序里,用户的发出的每一条命令都是可以撤销(Undo)的,例如修改了产品的价格,按一下撤销按钮就能恢复原来的价格,当然还可 以通过重做(Redo)再回到新的价格。为了实现这个功能,应用程序里维护了一个用于存放命令的类似栈的数据结构(CommandStack),每一条执 行过的命令都被存放在那里,需要撤销时取出最近一条命令进行撤销。
1392 0
|
图形学
UNITY 多SCENE加载与编辑
Unity内部场景的加载分为两步: Loading。是指从文件、内存(主要是Streamed scene AssetBundle)中加载Scene的内容,创建并读取所有相关的Game objects、Assets以及Scene game managers。