【发布时间】:2014-09-04 15:10:01
【问题描述】:
我在日志中收到此异常
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'CCSprite is not using the same texture id'
我想要做的是将普通的“myfile.png”文件添加到SpriteBatchNode
**批处理节点的声明
CCSpriteBatchNode *_backgroundLayer = [CCSpriteBatchNode batchNodeWithFile:@"sprites.png"];
** 用法
这条线很完美
CCSprite *sprite1 = [CCSprite spriteWithSpriteFrameName:@"PngFileKeptInSpriteSheet.png"];
[_backgroundLayer addChild:sprite1];
但是,当我使用直接 *.png 文件添加到批处理节点时,它会崩溃
CCSprite *sprite2 = [CCSprite spriteWithFile:@"myfile.png"];
在线崩溃
[_backgroundLayer addChild:sprite2];
经过进一步调试,我发现:
断言失败在文件CCSpriteBatchNode.m中
内部方法-(void) addChild:(CCSprite*)child z:(NSInteger)z tag:(NSInteger) aTag
在线NSAssert( child.texture.name == textureAtlas_.texture.name, @"CCSprite is not using the same texture id");
附: :“正常”是指不是取自 *.plist 文件
【问题讨论】:
-
cocos2d是什么版本的?
-
COCOS2D_VERSION 0x00010001
-
那是 1.1 还是你是编译器?
-
哎呀!抱歉……是 cocos2d v1.0.1
-
这是一个新应用吗?如果我强烈建议迁移到 v2 或 v3。
标签: cocos2d-iphone ccspritebatchnode