Advertisement
Hendrix000007

Untitled

Mar 21st, 2012
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.82 KB | None | 0 0
  1. --FUNCTION FOR PLAYERMOVEMENT
  2. --FUNCTION FOR PLAYERMOVEMENT
  3. local playerMovement = function()
  4.     if nil ~= player then
  5.         if player.state == STATE_WALKING then
  6.             print("walking") --DEBUGIUNG
  7.             player:applyForce(player.direction * 20, 0, player.x, player.y)
  8.         else
  9.             print("Idle") --DEBUGIUNG
  10.                 local vx, vy = player:getLinearVelocity()
  11.                     if vx ~= 0 then
  12.                         player:setLinearVelocity(vx * 0.9, vy)
  13.                     end
  14.                 end
  15.     else
  16.         player:removeSelf()
  17.         player=nil
  18.     end
  19. end
  20.  
  21. --[[
  22. --------------------------
  23. Result in Terminal window:
  24. ---------------------------
  25.  
  26. Runtime error
  27.     /Users/Hendrix/Desktop/MM/GameLogic.lua:192: attempt to compare nil with number
  28. stack traceback:
  29.     [C]: ?
  30.     /Users/Hendrix/Desktop/MM/GameLogic.lua:192: in function </Users/Hendrix/Desktop/MM/GameLogic.lua:185>
  31.     ?: in function <?:215>
  32. --]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement