02.02.2013 Views

Flash MX 2004 Games : Art to ActionScript

Flash MX 2004 Games : Art to ActionScript

Flash MX 2004 Games : Art to ActionScript

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

16 mc.scale = 1.0;<br />

17 }<br />

18<br />

19 House.orgX = House._x;<br />

20 House.orgY = House._y;<br />

21 House.scale = 0.6;<br />

22<br />

23 Fence.orgX = Fence._x;<br />

24 Fence.orgY = Fence._y;<br />

25 Fence.scale = 0.8;<br />

26<br />

27 s<strong>to</strong>p();<br />

Listing 17.12<br />

Chapter 17: Platformers<br />

Notice that in addition <strong>to</strong> s<strong>to</strong>ring a starting location (orgX, orgY) we also s<strong>to</strong>re a scale for each<br />

movie clip. In this example even the fence and the houses are movie clips. The scale value does<br />

not relate <strong>to</strong> the standard movie clip parameter ‘_scale’; we do not use it <strong>to</strong> resize the clip, we use<br />

it <strong>to</strong> work out how far it should move. Take a look at the revised ‘move’ function.<br />

1 function move() {<br />

2 var i, name, dx, mc;<br />

3<br />

4 x += moveX;<br />

5 y += moveY;<br />

6<br />

7 switch (action){<br />

8 case WALKRIGHT:<br />

9 case STOPRIGHT:<br />

10 case STARTRIGHT:<br />

11 if (platform!=""){<br />

12 dx = eval(platform)._x - _x;<br />

13 if (dx30){<br />

14 platform = "";<br />

15 initAction(FALLRIGHT);<br />

16 }<br />

17 }<br />

18 break;<br />

19 case WALKLEFT:<br />

20 case STOPLEFT:<br />

21 case STARTLEFT:<br />

22 if (platform!=""){<br />

23 dx = eval(platform)._x - _x;<br />

24 if (dx30){<br />

277

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!