Graphics Programs Reference
In-Depth Information
Figure 5.34 A sense of 3D space using elliptical motion
Let's push the sense of a 3D space a little more. Although the elliptical orbit is more
3D-looking, the effect suffers from the fact that the object is always the same size.
Our experience tells us that objects farther away from us should appear smaller than
objects that are close to us, so we need some way to systematically vary the size of
the object. Fortunately, there is a very nice relationship that we can take advantage
of. Referring to the Figure 5.34, we would expect that as the y-axis value of the object
increases (from top to bottom), then the size of the object should increase. Let's see
how we can convert this concept into ActionScript.
We'll start by defining a variable under object characteristics named minSize , which will
represent the minimum size that the object will be when it is the farthest away from us.
This size is expressed as a percentage of the original size, which we will assume to be
the size when the object is closest to us.
5
6
7
8
9
10
yro = path_mc._height/2; // yro = initial path y-radius
angle = 0; // angle = starting angle on path
// define minimum object size as a percent of the original
minSize = 60;
Next, let's calculate the minimum and maximum y-axis values of the ellipse, which we'll
call ymin and ymax respectively. Since the user can control the path, we will need to put
this calculation inside the frame loop so that it can be updated to match user input.
 
Search WWH ::




Custom Search