Let's analyze the script: Line 1: create the movie clip instanced as "terrain" Line 2: set the style of the line I am going to draw Line 3: initialize a flag saying that I am not drawing Line 4: Actions to perform when the mouse is "down" (when I click the mouse) Lines 5-8: If i am not drawing, move the "pen" at current mouse location and set the drawing variable at true, to tell the script that now I am drawing Lines 9-13: If I am drawing, every time I enter the frame a line is traced from the last line drawn to the actual mouse location Lines 15-19: If the mouse is "up" (I am not clicking the mouse), the imdrawing variable is set back to false value each time I enter the frame. The onEnterFrame here may seem useles but without it, the script won't work and if you start drawing, you will continue drawing even if the mouse button is not pressed. Lines 1-5: These instructions are execute only once, when the ball firstly appears on the stage. If you followed my flash game creation tutorial you are familiar with those instructions. I am defining ball x and y speed (set to 0, the ball does not move) and the gravity.
Lines 12-13: The yspeed value is added to _y (old line 12) only if the player is in the air. Look at the +1 in the _y+_height/2+1. I need to "forecast" next player's position and if I find it will be in the ground, then I stop considering the gravity. Otherwise lines 14-15 set yspeed to zero. |
| w__w___w.j__ava__2s__._c__o__m__ | Contact Us |
| Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
| All other trademarks are property of their respective owners. |