Advertisement
dragnoz

Defold - basic keypress detect

Feb 19th, 2017
382
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. --prehash the inputs
  2. local input_left = hash("left")
  3. local input_right = hash("right")
  4. local input_jump = hash("jump")
  5.  
  6.  
  7.  
  8. function init(self)
  9. msg.post(".", "acquire_input_focus")
  10. end
  11.  
  12.  
  13. function on_input(self, action_id, action)
  14.  
  15. if action_id == input_left then
  16. print("left")
  17. else if action_id == input_right then
  18. print("right")
  19. else if action_id == input_jump then
  20. print("jump")
  21.  
  22. end
  23. end
  24. end
  25.  
  26. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement