Advertisement
Guest User

Untitled

a guest
May 21st, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.68 KB | None | 0 0
  1. -----------------------------------------------------------------------------------------
  2. --
  3. -- main.lua
  4. --
  5. -----------------------------------------------------------------------------------------
  6.  
  7. -- Your code here
  8. local tapCount = 0
  9.  
  10. local Background = display.newImageRect("background.jpg", display.contentWidth, display.contentHeight)
  11. Background.x = display.contentCenterX
  12. Background.y = display.contentCenterY
  13.  
  14. local Platform = display.newImageRect("platform.jpg", display.contentWidth, 100)
  15. Platform.x = display.contentCenterX
  16. Platform.y = display.contentHeight - 50
  17.  
  18. local Character = display.newImageRect("character.png", 100, 100)
  19. Character.x = display.contentCenterX
  20. Character.y = 171
  21.  
  22. local tapText = display.newText(tapCount, display.contentCenterX, 50, native.systemFont, 56)
  23.  
  24. ----------------------------------------------------------------------------------------physics
  25.  
  26. local function jumpLeft()
  27.   Character.x = 130
  28.   Character.xScale = 1
  29.   tapCount = tapCount+1
  30.   tapText.text = tapCount
  31. end
  32.  
  33. local function jumpRight()
  34.   Character.x = 330
  35.   Character.xScale = -1
  36.   tapCount = tapCount+1
  37.   tapText.text = tapCount
  38. end
  39.  
  40. local buttonWidth = display.contentWidth / 2;
  41. local buttonHeight = display.contentHeight;
  42.  
  43. local buttonLeft = display.newRect(buttonWidth / 2, buttonHeight / 2, buttonWidth, buttonHeight);
  44. local buttonRight = display.newRect(buttonWidth / 2 + buttonWidth, buttonHeight / 2, buttonWidth, buttonHeight);
  45.  
  46. buttonLeft:setFillColor(0,0,0,0);
  47. buttonRight:setFillColor(0,0,0,0);
  48.  
  49. buttonLeft.isHitTestable = true;
  50. buttonRight.isHitTestable = true;
  51.  
  52. buttonLeft:addEventListener("tap", jumpLeft)
  53. buttonRight:addEventListener("tap", jumpRight)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement