Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -----------------------------------------------------------------------------------------
- --
- -- main.lua
- --
- -----------------------------------------------------------------------------------------
- -- Your code here
- local tapCount = 0
- local Background = display.newImageRect("background.jpg", display.contentWidth, display.contentHeight)
- Background.x = display.contentCenterX
- Background.y = display.contentCenterY
- local Platform = display.newImageRect("platform.jpg", display.contentWidth, 100)
- Platform.x = display.contentCenterX
- Platform.y = display.contentHeight - 50
- local Character = display.newImageRect("character.png", 100, 100)
- Character.x = display.contentCenterX
- Character.y = 171
- local tapText = display.newText(tapCount, display.contentCenterX, 50, native.systemFont, 56)
- ----------------------------------------------------------------------------------------physics
- local function jumpLeft()
- Character.x = 130
- Character.xScale = 1
- tapCount = tapCount+1
- tapText.text = tapCount
- end
- local function jumpRight()
- Character.x = 330
- Character.xScale = -1
- tapCount = tapCount+1
- tapText.text = tapCount
- end
- local buttonWidth = display.contentWidth / 2;
- local buttonHeight = display.contentHeight;
- local buttonLeft = display.newRect(buttonWidth / 2, buttonHeight / 2, buttonWidth, buttonHeight);
- local buttonRight = display.newRect(buttonWidth / 2 + buttonWidth, buttonHeight / 2, buttonWidth, buttonHeight);
- buttonLeft:setFillColor(0,0,0,0);
- buttonRight:setFillColor(0,0,0,0);
- buttonLeft.isHitTestable = true;
- buttonRight.isHitTestable = true;
- buttonLeft:addEventListener("tap", jumpLeft)
- buttonRight:addEventListener("tap", jumpRight)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement