The coordinate system used in Flash is called the Cartesian coordinate system. (This may sound vaguely familiar to you from math classes, and if so, the information here should be a simple review.) Understanding how the Cartesian coordinate system is set up and how to use it is very important for a game developer. Why, exactly? Because in your games you will be creating and moving objects around the screen, using ActionScript to tell an object which coordinates to move to. And to write ActionScript that does this, you've got to have an understanding of the coordinate system. In this section I'll (re)acquaint you with this all-important grid. We'll also discuss how the Flash coordinate system measures angles. ## Cartesian CoordinatesThe Cartesian coordinate system is grid-based (made up of many equal-sized imaginary squares), with a horizontal axis called the x-axis and a vertical axis called the y-axis. The way we look at this grid in Flash positions the negative side of the y-axis higher than the positive side. Actually, there is no difference at all between the two coordinate systems you've just seen. What is different is how we are observing them. If you stand on your head to view an object, then only the way you are observing it has changed, not the object itself. That is what's happening here. In math class you observed the coordinate system one way; in Flash, you will observe it upside-down and backwards.
A Cartesian coordinate is a set of two numbers that describe the position of a point. In math, the two numbers in the coordinate are usually grouped in parentheses, like this: (4, 8). The 4 represents a distance along the x-axis, and the 8 represents a distance along the y-axis.
## AnglesAngles are used in two ways in Flash: They are used to rotate objects, and they are used with the trigonometric functions that will be discussed later in this chapter. But before you can use angles to do anything, you need to understand how they are measured in the Flash coordinate system. Positive angles are measured from the x-axis, rotated in a clockwise direction, and with a fixed point at the origin. Angles are measured in degrees and can have a value of 0° to 360°. The entire coordinate system is made up of four quadrants separated by the axes. Each quadrant covers 90°.
In addition to degrees, there is another common way to measure angles: in radians. One full rotation is 2p radians. With degrees, we know that one rotation is 360°, so each quarter rotation is 90°. Likewise, with radians, since a full rotation is 2p, each quarter rotation is p/2. For those who may not remember, p (pi, or myPI = Math.PI; So why do you need to know about radians? Because everything you do in Flash with angles with one exception needs to be expressed in radians.
The only time you can use degrees directly in Flash is when you're changing the |

Macromedia Flash MX Game Design Demystified: The Official Guide to Creating Games with Flash -- First 1st Printing -- CD Included

ISBN: B003HP4RW2

EAN: N/A

EAN: N/A

Year: 2005

Pages: 163

Pages: 163

Authors: Jobe Makar

Similar book on Amazon

- Structures, Processes and Relational Mechanisms for IT Governance
- Measuring and Managing E-Business Initiatives Through the Balanced Scorecard
- Technical Issues Related to IT Governance Tactics: Product Metrics, Measurements and Process Control
- Managing IT Functions
- Governing Information Technology Through COBIT

flylib.com © 2008-2017.

If you may any questions please contact us: flylib@qtcs.net

If you may any questions please contact us: flylib@qtcs.net