Graphics Programs Reference
In-Depth Information
each object, we can set its scale to be a percentage of its distance ratio as shown in
line 45.
44
45
46
47
// set the size as a percent of its distance ratio
thisObj._xscale = thisObj._yscale = 100 * dr;
}
Save your file as 6_1_fishy_DONE.fla and test your movie. Your results should be
similar to Figure 6.5. The size and position of the fish in your movie will, of course,
be different since they are being randomly generated.
Figure 6.5 Initial output with incorrect ordering
Looking closely at the figure, we see there is a problem. Something fishy is going on.
Although the fish vary in size and position, there are smaller fish in front of larger ones.
This is not correct because the smaller ones are farther back in 3D space and should be
behind larger fish. What we need is some way to order or sort the fish so that the ones
with lower z - values will be in front of those with higher z - values. Recall that z = 0 is
located at the screen and that positive numbers go into the screen.
Step 5: Z-sorting the objects
Add the script below to what you already have. We can get the proper ordering or
Search WWH ::




Custom Search