Skip to content

Instantly share code, notes, and snippets.

@Mr-Coxall
Created April 18, 2018 13:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mr-Coxall/8fea4eac4a3ed58a4d362d19f1cff6cb to your computer and use it in GitHub Desktop.
Save Mr-Coxall/8fea4eac4a3ed58a4d362d19f1cff6cb to your computer and use it in GitHub Desktop.
-----------------------------------------------------------------------------------------
--
-- 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