Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cocos2d: Move a Sprite along a path/bezier?

I need to move a sprite from one CGPoint to another using Cocos2d for the Iphone. The problem is that the animation should be along a bezier.

Basically I would use this :

id move = [CCMoveTo actionWithDuration:.5f position:ccp(100,200)];
[sprite runAction:move];

Now how can I do this in a non linear path ?

like image 378
eemceebee Avatar asked May 14 '10 14:05

eemceebee


2 Answers

Try this

ccBezierConfig bezier;
bezier.controlPoint_1 = ccp(0, s.height/2);
bezier.controlPoint_2 = ccp(300, -s.height/2);
bezier.endPosition = ccp(300,100);

id bezierForward = [CCBezierBy actionWithDuration:3 bezier:bezier];
like image 115
elementsense Avatar answered Nov 07 '22 23:11

elementsense


Well, actually I was once again too fast seeking for help.

Found the solution, there is a method : CCBezierTo

like image 37
eemceebee Avatar answered Nov 08 '22 00:11

eemceebee