Last active
August 29, 2015 14:15
-
-
Save dantes2023/31c0732c29709f8705d1 to your computer and use it in GitHub Desktop.
1 Button with two functions
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
-- 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