加载SpriteBuilder中的scene为何不能带后缀
2015-09-18 14:28
302 查看
我们在Xcode中切换SpriteBuilder中的scene时,一般使用的是如下代码:
但是实际我们知道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的文件,这样是可以的:
-(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"];
相关文章推荐
- 加载SpriteBuilder中的scene为何不能带后缀
- UITableview控件基本使用
- mosquitto-1.4.2安装配置教程
- JSONValue.parse出错
- win7 64位系统下运行Jbuilder2006
- iOS学习笔记—— UINavigationController(一)实现页面跳转&添加左右侧按钮
- this compilation unit is not on the build path of a java project
- android ui分析 - 今日头条UI主界面
- 猫学习IOS(十五)UI以前的热的打砖块游戏
- HDU5400 Arithmetic Sequence
- Implement Stack using Queues
- xcode7.0-iOS9新特性之三:界面适配利器:UIStackView
- UITabBarItem 如何触发点击事件
- 【Mockplus教程】重命名
- 【Mockplus教程】删除
- 【Mockplus教程】复制/克隆
- 关机时windows发的消息WM_QUERYENDSESSION
- 【Mockplus教程】收藏和重用
- 【Mockplus教程】标尺和参考线
- UILabel设置行间距及字体色彩