开发者

Cocos2d: Move a Sprite along a path/bezier?

开发者 https://www.devze.com 2022-12-30 20:57 出处:网络
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.

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 ?


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];


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

Found the solution, there is a method : CCBezierTo

0

精彩评论

暂无评论...
验证码 换一张
取 消