Cocos2d 2.x: an understanding of ccBezierConfig beheavor

I am on this since some time ago I asked a question and the user kindly answered me, explaining that there is this plugin tool that I can use to create quick prototypes of bezier curves.

I tried and produced this:

That's what I produced with the tool

I thought this would be perfectly translated in this ccBezierConfig:

ccBezierConfig bezier; self.position = CGPointMake(-10.0f, 400.0f); bezier.controlPoint_1 = CGPointMake(160, 190.0f); bezier.controlPoint_2 = CGPointMake(200, 190.0f); bezier.endPosition =CGPointMake(340.0f,280.0f); id bezierForward = [CCBezierBy actionWithDuration:3 bezier:bezier]; [self runAction: [CCSequence actions: bezierForward, [CCHide action], nil]]; 

Unfortunately, the path I get is not what I expected. The symbol starts to move from the upper left corner of the screen, and then just rises, and I do not see the expected movement.

Any explanation for what I'm doing wrong?

Btw .. I am using Cocos2d 2.0 on iOS 6.0, the 4th generation iPod touch retina display.

EDIT:

Another example.

I thought that this configuration would look like this , and then do the symmetrical thing from end to start, but upside down.

Any suggestions on what I'm doing wrong?

  ccBezierConfig bezier; self.position = CGPointMake(0.0f, 150.0f); bezier.controlPoint_1 = CGPointMake(-20.0f, 290.0f); bezier.controlPoint_2 = CGPointMake(260, 290.0f); bezier.endPosition =CGPointMake(340.0f,150.0f); id bezierForward = [CCBezierBy actionWithDuration:3 bezier:bezier]; ccBezierConfig bezier2; bezier2.controlPoint_1 = CGPointMake(340.0f, 10.0f); bezier2.controlPoint_2 = CGPointMake(80, 10.0f); bezier2.endPosition =CGPointMake(-20.0f,150.0f); id bezierReturn = [CCBezierBy actionWithDuration:3 bezier:bezier2]; [self runAction: [CCSequence actions: bezierForward, bezierReturn, [CCHide action], nil]]; 
+2
source share
1 answer

I used CCBezierBy, but the examples are based on the CCBezierTo formula. Therefore, everything works as expected if I use CCBezierTo set to CCBezierBy.

+4
source

Source: https://habr.com/ru/post/1498674/


All Articles