-
Book Overview & Buying
-
Table Of Contents
Mastering Cocos2d Cross-Platform Game Development
By :
If you don't know what a Bézier curve is, it's basically a line that goes from point A to point B over a curve. Instead of being a straight line with two points, it uses a second set of points called control points that bend the line in a smooth way. When you want to apply movement with animations in Cocos2d, it's very tempting to queue up a bunch of MoveTo actions in a sequence. However, it's going to look a lot nicer ( in both the game and the code) if you use a smoother Bézier curve animation.
Here's a good example of what a Bézier curve looks like:

As you can see, the red line goes from point P0 to P3. However, the line is influenced in the direction of the control points, P1 and P2.
Let's list a few examples where it would be a good choice to use a Bézier curve instead of just the regular MoveTo or MoveBy actions:
A character that will perform a jumping animation, for example, in Super Mario Bros
A boomerang as a weapon...
Change the font size
Change margin width
Change background colour