CCSprite: setTexture doesn't work when the sprite is rendered using a CCSpriteSheet
- by srikanth rongali
My code is in cocos2d.
I am getting this error in my code.
To get the fast animation I used CCSpriteSheet
CCSpriteSheet *danceSheet = [CCSpriteSheet spriteSheetWithFile:@"new1.png"];
[self addChild:danceSheet];
CCSprite *danceSprite = [CCSprite spriteWithTexture:danceSheet.texture rect:CGRectMake(0, 0, 119, 320)];
[danceSheet addChild:danceSprite];
danceSprite.position = ccp(danceSprite.contentSize.width/2,danceSprite.contentSize.height/2);
CCAnimation *danceAnimation = [CCAnimation animationWithName:@"dance" delay:0.1f];
int frameCount = 0;
for (int x = 0; x < 13; x++)
{
// create an animation frame
CCSpriteFrame *frame = [CCSpriteFrame frameWithTexture:danceSheet.texture rect:CGRectMake(x*119,0,119,320) offset:ccp(0,0)];
[danceAnimation addFrame:frame];
frameCount++;
NSLog(@"frameCount value: %d", frameCount);
if (frameCount == 13)
break;
}
CCAnimate *danceAction = [CCAnimate actionWithAnimation:danceAnimation restoreOriginalFrame:NO ];
[danceSprite runAction:danceAction];
But when I touched the screen it is giving the error
CCSprite: setTexture doesn't work when the sprite is rendered using a CCSpriteSheet