Theme: Implementation of ball moving using Bezier curve
I think it’s time to finally implement a ball moving by previously constructed Bezier curve.
As usual, we are starting with definitions for global variables. Fortunately, we have only one new variable in this part of the tutorial – currBezierPoint.
It is used as a pointer to the current Bezier point so we can cycle from the first to the last Bezier point and change current position of the ball.
Here is the code for cycling through the Bezier points and drawing ball movement (by the way, this code is placed in the main loop of the program):
Of course, don’t forget to draw a simple ball movie clip called ball_mc!
It remains to mention still one thing. Every time when we call the function that computes a new Bezier curve, we must reset currBezierPoint to point to the first Bezier point!
It’s done in the next function:
Well, it seems that’s all. Simple, don’t you think so? Here you can test the program: