Game Development Reference
In-Depth Information
It's interesting to contrast the o_]haT and o_]haU properties with the daecdp and se`pd properties.
They both modify the size of an object, but the daecdp and se`pd properties use pixel values. Let's
make a few small changes to the kjCnks>qppkj?he_g and kjOdnejg>qppkj?he_g event handlers to
test it:
1. Make the following changes to the kjCnks>qppkj?he_g and kjOdnejg>qppkj?he_g event handlers
by replacing the original code with the code in bold:
bqj_pekjkjCnks>qppkj?he_g$arajp6IkqoaArajp%6rke`
w
dehhL]ca*_]p* se`pd'9-17
dehhL]ca*_]p* daecdp'9-17
y
bqj_pekjkjOdnejg>qppkj?he_g$arajp6IkqoaArajp%6rke`
w
dehhL]ca*_]p* se`pd)9-17
dehhL]ca*_]p* daecdp)9-17
y
2. Save the I]ej*]o file and test the project.
Click both the grow and shrink buttons a few times, and you should see something interesting hap-
pen. The cat will grow in both directions, but unless the cat's height in pixels is exactly the same as
its width, you'll soon start to notice that it will begin to distort slightly. This is because the directives
are adding the same number of pixels evenly for both the height and width, even though the cat's
dimensions weren't even to begin with. o_]haT and o_]haU avoid this problem by scaling the object
proportionately in all dimensions.
It's important to understand these subtle differences because sometimes using the daecdp and se`pd
properties is preferable to using o_]haT and o_]haU, and vice versa.
Vanishing!
The next little trick uses the reoe^ha property to make the cat disappear. The reoe^ha property is
a little different from the others you've looked at so far because it uses Boolean values. (As discussed,
Boolean values are values that can be only pnqa or b]hoa.) This allows you to use a bit of programming
sleight-of-hand to make a toggle button . You'll be able to switch (or toggle ) the cat's visibility on and
off with only one button. But before you do that, let's get the basic visibility button up and running.
1. Create a button called Reoe^ehepu>qppkj in the same way you created the previous buttons.
2. Open the DehhL]ca symbol. Select the buttons layer if it isn't already selected.
 
Search Nedrilad ::




Custom Search