Graphics Programs Reference
In-Depth Information
Figure 5.23 Example of variation in rotational angle
Let's add a statement to the script that says whatever angle an object is on the circle,
rotate that object the same amount around its registration point. Save your movie and
test it. You should see the six dolphins in the formation shown in Figure 5.23 above
rotating in a circular orbit.
29
30
31
32
33
34
35
36
37
38
39
// calculate the x- and y-coordinates
this["object"+i]._x = xc + r * Math.cos(a);
this["object"+i]._y = yc + r * Math.sin(a);
// rotate each object about its center point
this["object"+i]._rotation = myAngle;
}
// update the startAngle increment
startAngle += 2;
}
Step 2: Create more complex motion
Although the dolphins rotate, they stay in the same formation. It would be more inter-
esting to vary the formation somewhat, similar to the way synchronized swimmers do.
It turns out we can do this by making the rotation of each object depend in some man-
 
Search WWH ::




Custom Search