Graphics Reference
In-Depth Information
7.5.3 Character Control
Since the character needs to be controlled via the keyboard, we create a global
action for the keydown event on the Stage. This is always executed when any
key is pressed.
In (1), we get a reference to the player symbol we created earlier and the
associated DOM element so that we can move this in the next steps with the
jQuery animate() function. In (2), we can respond to pressing the arrow keys,
and start the relevant animation. We save a reference to the anim motion ani-
mation as a symbol variable so that we can later possibly stop this in advance,
such as for a collision with an object 3. We also use the state symbol variable,
which is used in the loop behavior within the symbol, and move the playhead
to animation sequence (4).
Search WWH ::

Custom Search