Skip to content

Instantly share code, notes, and snippets.

@Mr-Coxall
Last active April 16, 2018 02:02
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/1713d3c464c6ab2e3617d8063f92dfae to your computer and use it in GitHub Desktop.
Save Mr-Coxall/1713d3c464c6ab2e3617d8063f92dfae to your computer and use it in GitHub Desktop.
-- simple touch code
local theBall = display.newImage( "./assets/sprites/ball.png" )
theBall.x = display.contentCenterX
theBall.y = display.contentCenterY
theBall.id = "ball object"
local function onBallTouched( event )
if ( event.phase == "began" ) then
print( "Touch event began on: " .. event.target.id )
elseif ( event.phase == "ended" ) then
print( "Touch event ended on: " .. event.target.id )
end
return true
end
theBall:addEventListener( "touch", onBallTouched )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment