Game Development Reference
In-Depth Information
lner]pabqj_pekjkjGauQl$arajp6Gau^k]n`Arajp%6rke`
w
eb$$arajp*gau?k`a99Gau^k]n`*HABP%
xx$arajp*gau?k`a99Gau^k]n`*NECDP%%
w
[]__ahan]pekjT9,7
++=llhubne_pekjsdajpdagauo]najkhkjcan^aejclnaooa`
[bne_pekjT9BNE?PEKJ7
y
***
I included this bit of fine-tuning in the class because if no friction is being applied while the charac-
ter is moving, its movement is a little more fluid and a little more responsive. It's entirely up to you
whether you'll feel the same way about the characters in the games you'll be designing.
Bounce variables
There are two new variables in this class that you haven't used before: [^kqj_aT and [^kqj_aU. These
variables are used to accept bounce values that will be sent to the class by the platforms that the
lh]uan object will be jumping on. Without these values available, the lh]uan object can't bounce on
platforms. You'll use a special collision utility to control how the player interacts with platforms (dis-
cussed later).
The variables [^kqj_aT and [^kqj_aU are unrelated to the >KQJ?A constant. The >KQJ?A constant is
used to define the “bounciness” of the lh]uan object. In the game that you'll be designing, the >KQJ?A
constant is used only to define by how much the lh]uan object will bounce when it hits the bottom
of the stage.
ahoaeb$u'lh]uanD]hbDaecdp:op]ca*op]caDaecdp)>KPPKI[KB[OP=CA%
w
[ru&9>KQJ?A7
u9op]ca*op]caDaecdp)lh]uanD]hbDaecdp)>KPPKI[KB[OP=CA7
[eoKjCnkqj`9pnqa7
y
Notice that the bottom of the stage is offset by 10 pixels, which gives you some space to add the
10-pixel-high ground graphic. This offset is defined by the >KPPKI[KB[OP=CA constant, which is defined
at the beginning of the class definition.
Player collision area
Another small but important change is that the cat's ^k`u subobject, which will be used as the colli-
sion area, is now assigned to a [_khheoekj=na] variable.
[_khheoekj=na]9pdeo*^k`u7
This is important because the code will access this property to check which part of the lh]uan object
should be checked for collisions with platforms.
 
Search Nedrilad ::




Custom Search