Check taps on different buttons

Hi,

I have two buttons on my app and i want to call the function showImage( ) only when both buttons have been pressed al least one time. How could i do that?

[lua]

local button_1 = display.newRoundedRect( common.centerX-200, common.centerY+200, 150, 50, 12 )

local button_2 = display.newRoundedRect( common.centerX+200, common.centerY+200, 150, 50, 12 )

local image = display.newImage ( “illustration.png”, 500, 500 )

image.alpha= 0

local function showImage(  )

transition.to(image, {time=1470, alpha=1, transition=easing.inOutExpo } )

end

button_question:addEventListener (“tap”, question)

button_answer:addEventListener (“tap”, answer)[/lua]

Sorry, the lines 11 and 12 are wrong

  1. button_1:addEventListener (“tap”, question)
  2. button_2:addEventListener (“tap”, answer)

Hi,

inside the 2 functions question and answer, add the line : self.isTap=true, where self is a reference to button1 or 2.

And then write the showImage function at the end of the 2 functions question & answer.

local function showImage( ) if button1.isTap and button2.isTap then transition.to(image, {time=1470, alpha=1, transition=easing.inOutExpo } ) end end

Yvan.

Sorry, the lines 11 and 12 are wrong

  1. button_1:addEventListener (“tap”, question)
  2. button_2:addEventListener (“tap”, answer)

Hi,

inside the 2 functions question and answer, add the line : self.isTap=true, where self is a reference to button1 or 2.

And then write the showImage function at the end of the 2 functions question & answer.

local function showImage( ) if button1.isTap and button2.isTap then transition.to(image, {time=1470, alpha=1, transition=easing.inOutExpo } ) end end

Yvan.