Game Development Reference
In-Depth Information
nk^kp*rt9nk^kp*t)nk^kp*kh`T7
nk^kp*ru9nk^kp*u)nk^kp*kh`U7
nk^kp*kh`T9nk^kp*t7
nk^kp*kh`U9nk^kp*u7
++@eolh]unk^kp#orahk_epuej]`uj]ie_patpbeah`
`eolh]u*patp9Opnejc$RT6'nk^kp*rt'Xj'RU6 ±
'nk^kp*ru%7
y
y
y
The code uses a lot of the little techniques you've been looking at over the last few pages. Psaaj class
methods, properties, and PsaajArajp class events—they're all in here, playing their little parts.
Notice that there are separate Psaaj objects for each axis: [psaajT and [psaajU. They also each have
their own listeners. (I could have used a bit of programming gymnastics to make them use one lis-
tener, but I kept them separate for the sake of clarity.)
The kjIkpekjBejeodT and kjIkpekjBejeodU are called when the object completes its animation
sequence. Let's take a quick look at kjIkpekjBejeodU because it's making use of the Psaaj object's
properties in a way that you haven't yet seen:
lner]pabqj_pekjkjIkpekjBejeodU$arajp6Arajp%
w
r]npsaajK^fa_p6Psaaj9arajp*p]ncap]oPsaaj7
psaajK^fa_p*^acej9nk^kp*u7
psaajK^fa_p*bejeod9I]pd*_aeh$I]pd*n]j`ki$%&0,,%7
psaajK^fa_p*op]np$%7
y
Remember that the arajp*p]ncap object is the [psaajU object, so it needs to be cast as a Psaaj using
the ]o operator:
r]npsaajK^fa_p6Psaaj9arajp*p]ncap ]oPsaaj7
This is the first time you've seen an object being cast as a type other than Ikrea?hel.
The kjIkpekjBejeodU event handler assigns the [psaajU object a new ^acej and bejeod point and
then starts the animation again based on those new values:
1. It sets the Psaaj object's ^acej property as the robot's current u position. That's the position
where the last animation ended. So it makes sense that the animation should begin again from
that point:
psaajK^fa_p* ^acej 9nk^kp*u7
2. Next, you need to assign a new random finish point to the bejeod property:
psaajK^fa_p* bejeod 9I]pd*_aeh$I]pd*n]j`ki$%&0,,%7
 
Search Nedrilad ::




Custom Search