Try clicking on the Flash movie and then play with the arrow keys!
Here are a few things I learned: (this was programmed using actionscript 2.0)
- The keylistener.onKeyUp event only tells you that some key on the keyboard has been released, but not which key. At first I thought I could use Key.getCode() to found out which key, but it turns out Key.getCode() only tells you the most recent key that was pressed. This means that if you press and hold the down arrow, then press and hold the left arrow at the same time, then release the down arrow, the Key.getCode() method will tell the the left arrow because it was last key pressed, even thought the down arrow is the one that triggered onKeyUp.
- Hit tests are really easy in flash because movieclips already have a built in method called hitTest. I used it in code for the space bar. If you press the space bar nothing will happen unless you move the red square so it's touching the blue-green colored oval at the top. The code for the hit test is "if (s1.hitTest(npc)){bblHi._visible=true}". You just type the name of one movieclip (the instance name of the square is s1) and then .hitTest(instance name of second movieclip) (the blue green oval is called npc).
No comments:
Post a Comment