Skip to content

Instantly share code, notes, and snippets.

@dantes2023
Last active August 29, 2015 14:15
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 dantes2023/31c0732c29709f8705d1 to your computer and use it in GitHub Desktop.
Save dantes2023/31c0732c29709f8705d1 to your computer and use it in GitHub Desktop.
1 Button with two functions
-- A Example of code with Button with two functions
local player = display.newImageRect("player.png", 160,110)
local flip = display.newImageRect("swordIcon.png", 50,40)
flip.x = W/1 - 50
flip.y = H/2 + 200
local flip2 = display.newImageRect("swordIcon.png", 50,40)
flip2.x = W/1 - 50
flip2.y = H/2 + 200
local function trocarposicao( event )
if ( event.phase == "began" ) then
player.xScale = -1
flip.isVisible = false;
flip2.isVisible = true;
end
end
flip:addEventListener("touch", trocarposicao)
local function trocarposicao2( event )
if ( event.phase == "began" ) then
player.xScale = 1
flip.isVisible = true;
flip2.isVisible = false;
end
end
flip2:addEventListener("touch", trocarposicao2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment