I want to have a sprite scale up and down once every second to make it seem like it is bulging and pulsating. How can I do this?
views:
20answers:
1
+1
A:
You could use a simple [CCScaleTo ..] action or if you want to create your own "effect" you could advance the CCFiniteTimeAction. I would prefer the first one :
CCSprite * sprite = ...; // create the sprite.
sprite.anchorPoint = ccp( 0.5, 0.5 ); center the pivot
id myAction = [CCRepeatForEver actionWithActions:[CCScaleTo actionWithDuration:0.5 scaleX:2.0 ScaleY:2.0],[CCScaleTo actionWithDuration:0.5 scaleX:0.5 ScaleY:0.5], nil];
[sprite runAction:myAction];
use CCEase to make the animation nonlinear
id myAction = [CCRepeatForEver actionWithActions:[CCEaseInOut actionWithAction:[CCScaleTo actionWithDuration:0.5 scaleX:2.0 ScaleY:2.0] rate:2.0],[CCEaseInOut actionWithAction:[CCScaleTo actionWithDuration:0.5 scaleX:0.5 ScaleY:0.5] rate:2.0], nil];
this post may contain errors. but I hope you understand the way to come to the goal.
hhamm
2010-07-06 13:22:36