Trying to use CCEaseOut to slow CCSprite Movement

321 views Asked by At

I am trying to make my CCSprite come a gliding stop instead of an abrupt halt however I'm not too sure how to do this. I'm moving a CCSprite using CCActionMoveTo and CCEaseOut based on where the user taps; the sprite does move however doesn't glide to a halt. My code is below:

-(void) touchBegan:(UITouch *)touch withEvent:(UIEvent *)event
{
    CGPoint touchLoc = [touch locationInNode:self];
    CCActionMoveTo *actionMove = [CCActionMoveTo actionWithDuration:0.2f position:ccp(touchLoc.x, 150)];
    id ease = [CCEaseOut actionWithAction:actionMove rate:2];
    [_playerSprite runAction: ease];
}
2

There are 2 answers

0
Jack On

I would recommend you to read http://www.raywenderlich.com/24824/introduction-to-ai-programming-for-games tutorial, specifically the part on "Steering"

0
Mark On

Increase the easing rate to see a more profound effect. 2 is low, and it might not be obvious at that value. Perhaps you would like CCEaseExponentialOut as well.