user1286706
user1286706

Reputation: 57

How can i group multiple bezier paths in cocos2d

Can anyone help me on this. I am trying to make a path with multiple ccbezierpaths. This is my code.

self.move_duration = 1;
self.position = ccp((winSize.width)*0, (winSize.height)*0.5);

ccBezierConfig bezier1;
bezier1.controlPoint_1 = ccp((winSize.width)*0, (winSize.height)*0.5); // control point 1
bezier1.controlPoint_2 = ccp((winSize.width)*0.125, (winSize.height)*0.833); // control point 2
bezier1.endPosition = ccp((winSize.width)*0.25, (winSize.height)*0.5);

ccBezierConfig bezier2;
bezier2.controlPoint_1 = ccp((winSize.width)*0.375, (winSize.height)*0.833); // control point 1
bezier2.controlPoint_2 = ccp((winSize.width)*0.5, (winSize.height)*0.5); // control point 2
bezier2.endPosition = ccp((winSize.width)*0.625, (winSize.height)*0.833);

ccBezierConfig bezier3;
bezier3.controlPoint_1 = ccp((winSize.width)*0.75, (winSize.height)*0.5); // control point 1
bezier3.controlPoint_2 = ccp((winSize.width)*0.875, (winSize.height)*0.833); // control point 2
bezier3.endPosition = ccp((winSize.width), (winSize.height)*0.5);


id bezierto1 = [CCBezierTo actionWithDuration:self.move_duration bezier:bezier1];
id bezierto2 = [CCBezierTo actionWithDuration:self.move_duration bezier:bezier2];
id bezierto3 = [CCBezierTo actionWithDuration:self.move_duration bezier:bezier3];

It goes in a weird path. Does any one know how this is done the right. Thanks for your time and help

Sorry, for being so vague about the description. What i want to see to have bezier movement end at the end point and then the other one starts from there. instead it was doing this http://i.imgur.com/xZC6INa.png, thanks for the suggestion and the image mike.

Upvotes: 0

Views: 81

Answers (1)

YvesLeBorg
YvesLeBorg

Reputation: 9089

use

id seq = [CCSequence actions:bezierto1,bezierto2,bezierto3,nil];
[self runAction:seq];

and assuming cocos2d 2.x.

Upvotes: 1

Related Questions