Hey!
Is it possible to get the name of the current frame of an animated sprite?
Suppose I have this code for a 10 frame animation that I assign to a sprite:
CCSpriteFrameCache * cache = [CCSpriteFrameCache sharedSpriteFrameCache];
[cache addSpriteFramesWithFile:@"walk.plist"];
CCAnimation * animationWalk = [[CCAnimation alloc] initWithName:@"walk" delay:1/10.0];
for ( int i=1; i <= 10; ++i )
{
NSString * fname = [NSString stringWithFormat:@"walk%02i.png", i];
[animationIdle addFrame:[cache spriteFrameByName: fname]];
}
self.mySprite = [CCSprite spriteWithSpriteFrameName:@"walk01.png"];
id walkAction = [CCRepeatForever actionWithAction:[CCAnimate actionWithAnimation:animationWalk]];
[self.mySprite runAction:walkAction];
[self addChild:mySprite];
[self schedule:@selector(MyMethod:) interval:1/10];
Would there be a way for me to determine the name of the current frame (i.e. image) in "MyFunction"?
-(void) GameLoop:(ccTime)dt {
//Current frame of MySprite's animation is... walk01.png? walk02.png..? ...Which one is it???
}
Thanks!