Game Development Reference
In-Depth Information
The basic functionality of the kjCnks>qppkj?he_g and kjOdnejg>qppkj?he_g event handlers is identi-
cal to that used for the up and down buttons. But instead of using the u property, you're using the
o_]haT and o_]haU properties to scale the cat horizontally and vertically. You need to use both these
properties together to scale the cat evenly. If you use only one, say o_]haT, the cat will become very
fat around the middle without growing in height at all. (Try it and see!)
In fact, now that you know you can change two properties simultaneously, you can
also try this with the t and u properties. To move the cat up and down the hill diago-
nally, you can change the event handlers for the up and down buttons so that they
look like this:
bqj_pekjkjQl>qppkj?he_g$arajp6IkqoaArajp%6rke`
w
dehhL]ca*_]p*u)9-17
dehhL]ca*_]p*t'9-,7
eb$dehhL]ca*_]p*u8-.,%
w
dehhL]ca*_]p*u9-.,7
y
pn]_a$dehhL]ca*_]p*u%7
y
bqj_pekjkj@ksj>qppkj?he_g$arajp6IkqoaArajp%6rke`
w
dehhL]ca*_]p*u'9-17
dehhL]ca*_]p*t)9-,7
eb$dehhL]ca*_]p*u:..,%
w
dehhL]ca*_]p*u9..,7
y
pn]_a$dehhL]ca*_]p*u%7
y
There is no limit on the cat's x position, but it isn't difficult to add one with another eb
statement. Can you see how it might be done? Try it!
The o_]haT and o_]haU properties use values that refer to a ratio of the object's scale. That means
that all objects have a value of 1 at their original size. If you want to double the size of the object,
you need to give it a o_]haT and o_]haU value of 2. In the new code you've added, you're increasing
or decreasing the cat's scale by 0.1 each time the button is clicked, and that's a change of 10% of its
original size.
 
Search Nedrilad ::




Custom Search