1 Button with two functions

Well, there is a time ago was looking for a function that uses one button with two functions, and saw the people looking for it. I found a possible solution that worked for me. and I will share here.

Hello, I am Brazilian and sorry for any errors, my English is bad.
The sample code can be downloaded from the gist attached link.

I wanted a button that turned my character to the right and to the left by pressing a single button.
I did not, but got a hack that worked.

  • added 2 images in the same position x, y
  • created two functions

in each of the functions to program what you want and at the end add the following:

the first function:
flip.isVisible = false; - Your button.isVisible (button 1 hidden)
flip2.isVisible = true; - (And Appears 2)

the second function:
flip.isVisible = true; - Your button.isVisible (button 1 Appears)
flip2.isVisible = false; - (And hidden 2)

can change and if they have any tips on how to improve this, tell me

Works with Corona build #: