CCSprite:batched sprites应该使用与batchnode相同的纹理吗?

我不断得到一个崩溃,说: *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'CCSprite: Batched sprites should use the same texture as the batchnode'

我不太清楚这是什么意思。 我GOOGLE了崩溃,但没有结果。 而且这只有当我从我的游戏中的第二个场景回来后才回到我的第一个场景。

我再次检查我的代码,并确保我的精灵表中的所有图像都作为子节点添加到批处理节点。 我也确保在我的应用程序中不在我的精灵表中的图像作为一个孩子添加到我的图层而不是批处理节点。

无论如何是什么原因造成这次崩溃,我该如何解决?

谢谢!

编辑1 :这似乎是发生在我的应用程序的这一行:

 [self.spriteLeft setDisplayFrame:[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:imageName]]; 

我NSLog imageName和它返回:MyImage.png,然后我看我的plist和pvr.ccz,我加载和MyImage.png 肯定在那里。 所以我不知道为什么当一切看起来正确时就崩溃了。 此外,我确保我不使用spriteWithFile在我加载我的精灵表中的图像。

它只是意味着什么:当你使用纹理创buildCCSpriteBatchNode对象对象时,稍后当你向CCSpriteBatchNode添加精灵时,你添加到CCSpriteBatchNode的所有精灵必须来自同一个纹理。 例如:

 NSString *spriteName = @"agility"; // an example, this code comes from a method that returns the batchNode // for many status types NSString *plist = [NSString stringWithFormat:@"status_%@.plist",spriteName]; NSString *textureFileName = [NSString stringWithFormat:@"status_%@.pvr.gz",spriteName]; [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:plist textureFile:textureFileName]; CCSpriteBatchNode *batchNode = [CCSpriteBatchNode batchNodeWithFile:textureFileName]; // plist has a frame named status_agility_Ok.png CCSprite *frameStatusOk = [CCSprite spriteWithSpriteFrameName:[NSString stringWithFormat:@"status_%@_Ok.png",spriteName]]; [batchNode addChild:frameStatusOk]; // this will work, both the sprite and the batch node have the same texture CCSprite *frameStatusNotOk=[CCSprite spriteWithFile:@"someOtherTextureFile.pvr.gz"]; [batchNode addChild:frameStatusNotOk]; // this will fail an assertion and crash.