博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
加载SpriteBuilder中的scene为何不能带后缀
阅读量:6983 次
发布时间:2019-06-27

本文共 1234 字,大约阅读时间需要 4 分钟。

我们在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"];

转载地址:http://raxpl.baihongyu.com/

你可能感兴趣的文章
面向对象2
查看>>
c++测试题2016-6-2
查看>>
Nginx与Serssion一致性问题
查看>>
社会化工程攻击针对目标不再仅限最终用户
查看>>
Hadoop源码分析HDFS ClientProtocol——getBlockLocations
查看>>
AndroidWidget实践 --- EverydayTips开发(6)
查看>>
mysql 随机查询数据
查看>>
CodeIgniter学习笔记一
查看>>
workspace-project-target关系与解耦工程结构总结
查看>>
EhCache的配置
查看>>
Linux 设置时区
查看>>
在maven中引用github上的资源
查看>>
4、Angular JS 学习笔记 – 创建自定义指令 [翻译中]
查看>>
Flex手机开发-退出应用程序
查看>>
常用的7大排序算法汇总
查看>>
数字转化成时分秒(二)
查看>>
Golang通过syscall调用win32的Api
查看>>
阿里云Redis (安装包安装篇)
查看>>
Spring Bean的装配(非XML文件方式)
查看>>
100万“愤怒的小鸟”:中国手机开发者生存调查
查看>>