Guest User

Untitled

a guest
Feb 19th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. SCREEN_WIDTH = 320
  2. SCREEN_HEIGHT = 480
  3. LIMIT_FPS = 30
  4.  
  5. local player = {}
  6. player.x = SCREEN_WIDTH / 2
  7. player.y = SCREEN_HEIGHT / 2
  8.  
  9. -- Disable the status bar
  10. display.setStatusBar(display.HiddenStatusBar)
  11.  
  12. -- Add a background image
  13. local background = display.newImage ("background.png")
  14.  
  15. local playerObject = display.newText("@", player.x, player.y, "Courier Final Draft", 24)
  16. playerObject:setTextColor(255, 255, 255)
  17. playerIsRed = false
  18.  
  19. playerObject:addEventListener( "tap", playerObject)
  20.  
  21. function playerObject:tap( event )
  22. if playerIsRed then
  23. playerObject:setTextColor(255, 255, 255)
  24. playerIsRed = false
  25. else
  26. playerObject:setTextColor(255, 0, 0)
  27. playerIsRed = true
  28. end
  29. end
  30.  
  31. function playerMovement (event)
  32. playerObject.x = event.x
  33. playerObject.y = event.y
  34. end
  35. Runtime:addEventListener("touch", playerMovement)
Add Comment
Please, Sign In to add comment