Created
April 18, 2018 13:07
-
-
Save Mr-Coxall/8fea4eac4a3ed58a4d362d19f1cff6cb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
----------------------------------------------------------------------------------------- | |
-- | |
-- main.lua | |
-- | |
----------------------------------------------------------------------------------------- | |
-- Character move | |
local dPad = display.newImage( "./assets/sprites/d-pad.png" ) | |
dPad.x = 150 | |
dPad.y = display.contentHeight - 80 | |
dPad.id = "d-pad" | |
local upArrow = display.newImage( "./assets/sprites/upArrow.png" ) | |
upArrow.x = 150 | |
upArrow.y = display.contentHeight - 190 | |
upArrow.id = "up arrow" | |
local theCharacter = display.newImage( "./assets/sprites/Idle.png" ) | |
theCharacter.x = display.contentCenterX | |
theCharacter.y = display.contentCenterY | |
theCharacter.id = "the character" | |
function upArrow:touch( event ) | |
if ( event.phase == "ended" ) then | |
-- move the character up | |
transition.moveBy( theCharacter, { | |
x = 0, -- move 0 in the x direction | |
y = -50, -- move up 50 pixels | |
time = 100 -- move in a 1/10 of a second | |
} ) | |
end | |
return true | |
end | |
upArrow:addEventListener( "touch", upArrow ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment