Game Development Reference
In-Depth Information
In Figure 4-16, you can see where the Flash 2D plane lies in that system. With x increasing in
value to the right, and y increasing in value down, the screen falls into the lower right-hand
portion of the grid. This means that a 45-degree angle, cut from the center, would travel through
the grid as shown. This also means that 0 degrees is 45 degrees less than that line, which puts 0
to the direct right of the screen.
Figure 4-16. Angles in a Cartesian coordinates system in Flash
On the screen then, a rotation of 90 degrees will point directly down the screen. Since our Enemy
planes will fly directly down, we need to note this value. We will also have Enemy planes that fly in
from the right at a 45-degree angle, and from the left at 135-degree angle. These are the three
angle values we will need for the Enemy class. As you can see in the following code, we use the
dir value to set the angle we will need to move the Enemy :
public function init():void
{
x = startLocation.x;
y = startLocation.y;
switch(dir) {
case DIR_DOWN:
//***** Flex *****
//imageBitmapData = new PlaneGif().bitmapData;
//**** Flash *****
Search WWH ::




Custom Search