Game Development Reference
In-Depth Information
This code relies on the PsaajArajp class, so it needs to be imported with this directive:
eilknpbh*pn]joepekjo*PsaajArajp7
The code adds a IKPEKJ[BEJEOD event to the [psaaj object:
[psaaj*]``ArajpHeopajan$PsaajArajp*IKPEKJ[BEJEOD(kjIkpekjBejeod%7
IKPEKJ[BEJEOD is one of the events from the PsaajArajp class. It's triggered when the animation is
finished. In this case, it's set up to call the kjIkpekjBejeod event handler:
lner]pabqj_pekjkjIkpekjBejeod$arajp6Arajp%
w
arajp*p]ncap*ukuk$%7
y
arajp*p]ncap refers to the [psaaj object, not the object that's being animated . This is important to
remember. The ukuk method tells the [psaaj object to play its animation in reverse. Because this
event handler is called every time the animation finishes, the direction is reversed each time. Very easy
to implement, and it's a great effect.
There are six events in the PsaajArajp class that you can use with Psaaj objects (see Table 10-6).
Table 10-6. TweenEvent class events
TweenEvent class events
It's triggered when . . .
IKPEKJ[?D=JCA
The object being animated moves.
IKPEKJ[BEJEOD
The animation is finished.
IKPEKJ[HKKL
The animation is started from the beginning again.
IKPEKJ[NAOQIA
The animation is started after having been stopped.
IKPEKJ[OPKL
The animation stops playing.
IKPEKJ[OP=NP
The animation starts playing.
As you can see, with a bit of imagination there's quite a bit of untapped power here at your disposal to
build very sophisticated scripted animation environments for games. You can use these events to start,
stop, and change an object's animation based on any conditions in your game.
 
Search Nedrilad ::




Custom Search