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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

1 //Initialise firing<br />

2 for (i=0; i0.8){<br />

Let’s see how you are doing. What does the above condition statement mean? Can you remember<br />

what ‘&&’ means? It means ‘And’; when used in a condition statement it can be read in English<br />

as ‘if condition 1 And condition 2’ then do something. Here we have three conditions. The first<br />

condition checks the calculated value for the new _y position, ‘curY’. If ‘curY’ is greater than<br />

the current value of the Movie Clip’s _y value then the ‘Star’ must be moving down the screen<br />

(_y values increase down the screen). Next we test <strong>to</strong> see if the ‘Star’ is already exploding, in which<br />

case, the movie clip’s variable ‘exploding’ will evaluate <strong>to</strong> ‘true’. Finally the condition statement<br />

uses a ‘random’ test, otherwise every ‘Star’ would explode at its peak height. By using a random<br />

value we can make some ‘Stars’ explode at the peak height and others on the descent. So here is<br />

the code for the frame action labelled ‘Flying’.<br />

133

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

Saved successfully!

Ooh no, something went wrong!