Game Development Reference
In-Depth Information
u'9[ru7
++Ikrapdas]j`
r]nn]`eqo6ejp9)1,7
s]j`*t9n]`eqo&I]pd*_ko$[]jcha%7
s]j`*u9n]`eqo&I]pd*oej$[]jcha%7
y
lner]pabqj_pekjodkkp>qhhap$%6rke`
w
++>qhhap#orahk_epu
r]n^qhhap[Rt6Jqi^an9I]pd*_ko$[]jcha%&)-,7
r]n^qhhap[Ru6Jqi^an9I]pd*oej$[]jcha%&)-,7
++>qhhap#oop]nplkoepekj
r]nn]`eqo6ejp9)1,7
r]n^qhhap[Op]npT6Jqi^an9t'n]`eqo&I]pd*_ko$[]jcha%7
r]n^qhhap[Op]npU6Jqi^an9u'n]`eqo&I]pd*oej$[]jcha%7
++?na]pa^qhhapejop]j_a]j`]``eppkpdaop]ca
r]n^qhhap6>qhhap9jas>qhhap$^qhhap[Rt(^qhhap[Ru( ±
^qhhap[Op]npT(^qhhap[Op]npU(op]n%7
l]najp*]``?deh`$^qhhap%7
y
y
y
You'll look at each aspect of the code one bit at a time.
Moving the player
Button Fairy moves by accelerating toward the mouse. So the first thing the code needs to do is find
out where the mouse is. In the kjAjpanBn]ia event handler, the first directive finds the direction from
the object to the mouse, using the same formula used in Bug Catcher to rotate the frog's eyes:
[]jcha9I]pd*]p]j.$u)op]ca*ikqoaU(t)op]ca*ikqoaT%7
This is a number in radians , which is the system AS3.0's trigonometry functions use to measure angles.
One radian equals about 57.2958 degrees.
If you need to use an angle to rotate an object in your game, you need to convert the
value in radians to a value in degrees. The Movie Clip nkp]pekj property only under-
stands values in degrees.
To convert radians to degrees, multiply the value in radians by 180 divided by PI, like this:
n]`e]jo&$-4,+I]pd*LE%
If you want the []jcha variable in this example code to contain a value in degrees, the
directive looks like this:
[]jcha9I]pd*]p]j.$u)op]ca*ikqoaU(t)op]ca*ikqoaT%&$-4,+I]pd*LE%7
 
Search Nedrilad ::




Custom Search