Sophy Swicz
Sophy Swicz

Reputation: 1357

How can I slowly stop CCActions?

I'm trying to use the CCRipple 3D with Cocos2D like this:

-(void) addNewSpriteWithCoords:(CGPoint)p
   {
      id rippleAction = [CCRipple3D actionWithPosition:CGPointMake(p.x,p.y) radius:200 waves:10 amplitude:50 grid:ccg(32,24) duration:10];
      [self runAction:[CCSequence actions:rippleAction, [CCStopGrid action], nil]];
   }

(where p.x,and p.y correspond to the coordinates of every touch.)

But, when the effect is over it stops suddenly, and I have no idea how to change that? (I know that CCStopGrid stops the action in the grid, but I have no more clues)

Anyone knows how can I make the effect stops smoothly?

Thank you so much.

Upvotes: 2

Views: 1698

Answers (3)

phlebotinum
phlebotinum

Reputation: 1130

You can use one of the many 'ease' actions to smoothly scale the time another action takes.

And of course there are the API docs (Just two examples here, there are about 30 variations) But the many variations are all basically variations with different speeds, forward, revers and combinations of them.

Upvotes: 1

Sophy Swicz
Sophy Swicz

Reputation: 1357

Yeah, that worked Sold Out Activist (sorry for answer you so late)! what I did was:

-(void) addNewSpriteWithCoords:(CGPoint)p
 {          

 id rippleAction = [CCRipple3D actionWithPosition:CGPointMake(p.x,p.y) radius:150 waves:1 amplitude:50 grid:ccg(50,50) duration:0.9];
id rippleAction2 = [CCRipple3D actionWithPosition:CGPointMake(p.x,p.y) radius:150 waves:1 amplitude:25 grid:ccg(50,50) duration:0.8];

id rippleAction5 = [CCRipple3D actionWithPosition:CGPointMake(p.x,p.y) radius:150 waves:1 amplitude:5 grid:ccg(50,50) duration:1.1];
[fondo runAction:[CCSequence actions:rippleAction, rippleAction2, rippleAction5, [CCStopGrid action], nil]];
  }

Upvotes: 1

user481081
user481081

Reputation:

Wrap the CCSequence in CCSpeed:

CCSequence* sequence = // action bits
CCSpeed* speed = [CCSpeed actionWithAction:sequence speed:1.0f];

Save speed, say in a class variable, then using another function, say the standard update method to modify the speed however you like using setSpeed:.

Upvotes: 1

Related Questions