This is the error I receive:
* Terminating app due to uncaught exception ‘NSInternalInconsistencyException’, reason: ‘CCSprite: setTexture doesn’t work when the sprite is rendered using a CCSpriteBatchNode’
When I am trying to run through an animation.
Here is my creation of the animation:
_tokenAnimation = [[CCAnimation alloc] init];
int frameCount = 12;
for (int i = 1; i <= frameCount; i++)
{
CCSpriteFrame *frame = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:@"Token Ball 000%d.png", i]];
[_tokenAnimation addFrame:frame delay:0.1];
}
And here is me calling the animation- haven’t seen this before?
GameObject *creditPickup = [_creditPickups nextSprite];
creditPickup.position = ccp(_creditPosition.x, _creditPosition.y);
[creditPickup revive];
[creditPickup runAction:[CCRepeatForever actionWithAction:[CCAnimate actionWithAnimation:_tokenAnimation restoreOriginalFrame:NO]]];
[creditPickup runAction: [CCSequence actions:
[CCMoveBy actionWithDuration:5.0 position:ccp(-_winSize.width*1.5, 0)],
[CCCallFuncN actionWithTarget:self selector:@selector(invisNode:)], nil]];
I hear something about CCSpriteBatchNode’s being bad? If so how can I change the reading of my spritesheet??
Is there something else I’m doing wrong?
There’s your problem right there:
What that means is that none of the CCSprite added as children to a CCSpriteBatchNode can run the setTexture method. The reason is that they all have to use the same texture as their parent CCSpriteBatchNode. So cocos2d disables that method on sprites that are sprite-batched.
In your case it’s most likely that at least one of the sprite frames of the animation isn’t in the texture used by the CCSpriteBatchNode whose child sprite plays that animation.
Yes, it’s bad. So bad, it does moonwalks. 🙂