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.

Figure B.1 The graph of y = x 2<br />

Appendix B<br />

If an ease out is required then we need a different shape <strong>to</strong> the curve. In fact we need <strong>to</strong> flip the<br />

curve for both values. Flipping the time value will give a parameter moving by 1 − dt (if dt is a<br />

value between 0 and 1 as described above). The quadratic of 1 − dt is simply (1 − dt)(1 − dt)<br />

which can be multiplied out <strong>to</strong> give 1 − 2dt + dt 2 . We also want <strong>to</strong> flip the value parameter so the<br />

result is 1 − (1 − 2dt + dt 2 ) which simplifies <strong>to</strong> 2dt − dt 2 . So the curve we want is y = 2x − x 2 ,<br />

which is shown in Figure B.2.<br />

Figure B.2 The graph of 2x − x 2<br />

Such a curve is created with the code snippet:<br />

var dt = time/duration;<br />

_x = offset.x * dt *(2 - dt) + start.x;<br />

_y = offset.y * dt *(2 - dt) + start.y;<br />

In all the curves we shall study, we are using a delta time parameter dt that varies over the range 0<br />

<strong>to</strong> 1, <strong>to</strong> create a curve whose maximum value is also 1. We use the value of the curve multiplied<br />

397

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

Saved successfully!

Ooh no, something went wrong!