我在日志中收到此异常
*** 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");
PS:“正常”是指不是取自 *.plist 文件