Advertisement
Hendrix000007

MadMole wont jump

Jan 31st, 2012
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.11 KB | None | 0 0
  1. --PLAYER STATE SETTINGS
  2. local STATE_IDLE = "playerStill"
  3. local STATE_WALKING = "playerWalk"
  4. local STATE_JUMPING = "playerJump"
  5. local DIRECTION_LEFT = -1
  6. local DIRECTION_RIGHT = 1
  7.  
  8. local player = loader:spriteWithUniqueName("Player")
  9. -------------------------------------------------------------------------------------
  10. --BUTTON PART
  11. local buttonJumpPress = function( event )
  12.     if event.phase == "began" then
  13.         if player.canJump == true then
  14.             audio.play( boingSound, { channel= 3 } )
  15.             player:applyLinearImpulse(0, -10, player.x, player.y)
  16.             player:startAnimationWithUniqueName(player.state);
  17.         elseif event.phase == "ended" then
  18.             player:startAnimationWithUniqueName(player.state);
  19.         end
  20.     end
  21. end
  22. ---------------------------------------------------------------------------------------
  23. --COLLISION PART
  24. local function onLocalCollision( self, event )
  25.  
  26.     if ( event.phase == "began" ) then
  27.             if(event.other.lhTag == LevelHelper_TAG.GROUND) then
  28.                 player.canJump = true
  29.                 player:startAnimationWithUniqueName(player.state, player)
  30.             end
  31.              
  32.             if(event.other.lhTag == LevelHelper_TAG.GOLD) then
  33.                 score:addPoints(50)
  34.                 score:addToBag("gold_can")
  35.                 loader:removeSprite(event.other)
  36.             end
  37.            
  38.             if(event.other.lhTag == LevelHelper_TAG.CHEST) then
  39.                 score:addPoints(200)
  40.                 score:addToBag("chest")
  41.                 loader:removeSprite(event.other)
  42.             end
  43.              
  44.              if(event.other.lhTag == LevelHelper_TAG.KEY) then
  45.                 print( "Youve got the key " )
  46.                 score:addPoints(100)
  47.                 score:addToBag("key")
  48.                 loader:removeSprite(event.other)
  49.              end
  50.              
  51.              if(event.other.lhTag == LevelHelper_TAG.ENEMY) then
  52.                 print("enemy colide registred")
  53.                 goToRestartMenu()
  54.              end
  55.              
  56.              if(event.other.lhTag == LevelHelper_TAG.CHECKPOINT) then
  57.                 print("Next level please")
  58.                 player.collision = nil
  59.                 goToNextLevel()
  60.                 return
  61.              end
  62.              
  63.         elseif ( event.phase == "ended" ) then
  64.              if (event.other.lhTag == LevelHelper_TAG.GROUND) then
  65.             player.canJump = false
  66.         end
  67.     end
  68. end
  69. player.collision = onLocalCollision
  70. player:addEventListener( "collision", player )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement