Graphics Programs Reference
In-Depth Information
The general idea is as follows. We are first going to make duplicate copies of the object,
distribute those copies around the desired circle, and then apply what we learned ear-
lier to animate them. For reference, open 5_2_fishFerris.swf in the Chapter 5 folder.
Step 1: Getting started
Open 5_2_circRotation.fla in the Chapter 5 folder. The movie consists of five layers.
The bottom layer contains the sky and the circular elements of the Ferris wheel. These
can go on the background since they won't move. The spokes in the next layer will be
used to create the movement of the wheel. The fish objects (of which there is only one
at the moment) are layered on top of the wheel spokes but underneath the Ferris wheel
supports. The top layer, as usual, is the actions layer.
One fish car has been placed off the Stage. Duplicates will be created on the Stage, but
it is convenient to have the original out of view. Let's begin by defining the circular path
characteristics the cars will follow. The circle will be centered horizontally on the Stage
and 15 pixels above the vertical center of the Stage. The radius is set to 200 pixels.
1
2
3
4
5
// define the circular path characteristics
xc = Stage.width/2; // xc = horizontal center of circle
yc = Stage.height/2 - 15; // yc = vertical center of circle
r = 200; // r = radius of circle
Step 2: Define the object characteristics
Let's enter some information about the objects we are going to create. We want to
make it easy to handle the rotation of any number of objects rather than just one, so
let's define a variable named numberOfObjects and set it to some value, in our case 8.
We'll use a starting angle of 0 degrees as before so that the first fish created starts out
on the x-axis.
6
7
8
9
// define the object characteristics
numberOfObjects = 8; // number of objects to rotate
startAngle = 0; // starting rotation angle on the circle
Step 3: Determine the angle between objects
Once we have set the number of objects, we can calculate the angle between any two
objects, circleAngle , so that we can distribute them equally around the circle. For
Search WWH ::




Custom Search