My problem is, I did coding for a sprite. It should change it should change it's image from( 1, 2, 3). It should look like count down time to start a game. 1, 2, 3 are 3 png images. But the images are not displayed in equal intervals of time. I mean time between (1 - 2), (2 - 3) is not same. It is random. Please help me with my problem. Help me if there is better solution than what I am doing.(My animation should be like, before any game starts we see count down 1 then 2 then 3 then GO).
-(id)init { if((self = [super init])) { [[CCDirector sharedDirector] setAnimationInterval:60.0/60]; [[CCDirector sharedDirector] setDisplayFP开发者_如何学编程S:NO];
CCAnimation* numberAnimation = [CCAnimation animationWithName:@"countDown" delay: 60.0/60];
for( int i=1;i<4;i++)
[numberAnimation addFrameWithFilename: [NSString stringWithFormat:@"number_%02d.png", i]];
id numberAction = [CCAnimate actionWithAnimation: numberAnimation restoreOriginalFrame:NO];
id action2 = [CCFadeOut actionWithDuration:0.5f];
CCSprite *number;
number = [CCSprite spriteWithFile:@"number.png"];
....
} }
You'll have to update some of the classes used in this article a developer on my team wrote since it was written for Cocos2D 0.8.2 but I think this should do the trick for you...
http://getsetgames.com/2009/08/05/improving-the-performance-of-animating-sprites-in-cocos2d/
From a quick looks like you need to make the following changes...
- IntervalAction change to CCIntervalAction
- CocosAnimation change to CCAnimation (I think?)
- CocosNodeFrames change to CCNodeFrames (I think?)
You'll have to double check the Cocos2D 0.99 release notes. It details all the class names you'll need.
精彩评论