Game Development Reference
In-Depth Information
If you think you might use an object again at some point in your game, use naikra?deh`
without assigning a jqhh value. You can then see whether the object is on the stage by
checking whether the object's l]najp is jqhh . Here are two simple examples:
eb$ajaiuKja*l]najp9jqhh%
w
++Pdajpdak^fa_piqop^akjpdaop]ca***
y
eb$ajaiuKja*l]najp99jqhh%
w
++Pdajpdak^fa_piqopd]ra^aajnaikra`bnkipdaop]ca***
y
If the object doesn't have a parent container, then it's not on the stage, and vice
versa.
If you don't assign the variable that references the object a jqhh value, that object
still exists in Flash's memory. You can add it back to the stage again at any time using
]``?deh` .
Player vs. wall collisions
Exactly the same technique is used to check for collisions between the wall objects and the player:
Here's the S]hh class:
l]_g]ca
w
eilknpbh]od*`eolh]u*Ikrea?hel7
eilknpbh]od*arajpo*Arajp7
lq^he__h]ooS]hhatpaj`oIkrea?hel
w
lq^he_bqj_pekjS]hh$%
w
]``ArajpHeopajan$Arajp*=@@A@[PK[OP=CA(kj=``a`PkOp]ca%7
y
lner]pabqj_pekjkj=``a`PkOp]ca$arajp6Arajp%6rke`
w
++=``arajpheopajano
]``ArajpHeopajan$Arajp*AJPAN[BN=IA(kjAjpanBn]ia%7
]``ArajpHeopajan$Arajp*NAIKRA@[BNKI[OP=CA(kjNaikra`BnkiOp]ca%7
y
lner]pabqj_pekjkjNaikra`BnkiOp]ca$arajp6Arajp%6rke`
w
naikraArajpHeopajan$Arajp*AJPAN[BN=IA(kjAjpanBn]ia%7
naikraArajpHeopajan$Arajp*=@@A@[PK[OP=CA(kj=``a`PkOp]ca%7
 
Search Nedrilad ::




Custom Search