Advertisement
Guest User

problem 2

a guest
Apr 23rd, 2012
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var Player:MovieClip;
  2. var jumpCount:Number;
  3. var _isGrounded:Boolean;
  4. var _solidsArray:Array = [sldTerrain1, sldTerrain2];
  5.  
  6. function applyMovement():void
  7. {      
  8.     //handles velocity in the y direction
  9.     if (_isGrounded == false)
  10.     {
  11.         Player.vy -= 1;
  12.     }
  13.     else
  14.     {
  15.         Player.vy = 0;
  16.     }
  17. }
  18.  
  19. function checkGrounded():void
  20. {
  21.     for (var i:int = 0; i < _solidsArray.length; i++)
  22.     {
  23.         if (Player.hitTestObject(_solidsArray[i].hitTop))
  24.         {
  25.             //if player is moving down
  26.             if (Player.vy < 0)
  27.             {
  28.                 _isGrounded = true;
  29.                 jumpCount = 0;
  30.             }
  31.         }
  32.         else
  33.         {
  34.             _isGrounded = false;
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement