Game Development Reference
In-Depth Information
w
^qc*t9op]ca*op]caSe`pd7
++Naranoa$^kqj_a%^qc#orahk_epusdajepdepopdaop]caa`cao
^qc*rt&9)-7
y
eb$^qc*t8,%
w
^qc*t9,7
^qc*rt&9)-7
y
++Gaalpda^qc]^krapdas]pan
eb$^qc*u:op]ca*op]caDaecdp)/1%
w
^qc*u9op]ca*op]caDaecdp)/17
^qc*ru&9)-7
y
eb$^qc*u8,%
w
^qc*u9,7
^qc*ru&9)-7
y
++=llhu_khheoekjsepdlh]pbkni
bkn$r]ne6ejp9,7e8-,7e''%
w
?khheoekj*lh]uan=j`Lh]pbkni$Ikrea?hel$^qc%( ±
pdeoWlh]pbkni'eY(,*.(,%7
y
y
4. Save the I]ej[>qc?]p_dan*]o file and test the project. The three bugs flutter randomly around
the stage and bounce off the edges very realistically (like flies bumping into windows).
There's no magic to any of this. You just combined a few things that you already know how to do in
ways you haven't seen before.
Dynamic instance variables
In the constructor method, you declared and initialized rt and ru variables for the bugs and added
AJPAN[BN=IA event listeners like this:
bhu*rt9,7
bhu*ru9,7
bhu*]``ArajpHeopajan$Arajp*AJPAN[BN=IA(kj>qcIkra%7
The rt and ru variables were created dynamically (they're called dynamic instance variables ). All
that means is that you needed these variables, so you created them on the spot without checking with
the object's class whether it was okay to do so. In fact, the bug objects don't belong to any special
class, except the general Ikrea?hel class.
 
Search Nedrilad ::




Custom Search