I’m creating a game and I need to compare to values of set variables. The code I have written for this game is
local correctAnswer = 1
local numberOfTries = 0
local correctText = display.newText( “Good Job” ,200,400,nil, 50 )
correctText.isVisible = false
correctText:setTextColor( 255, 255, 255)
–My button touch to detemine the Game answer
local function AnswerOneTouch(touch)
–moving image answerOne
if (touch.phase==“begin”) then
local gameAnswer = 1
end
if (touch.phase==“moved”) then
end
if (touch.phase==“ended”) then
transition.to( answerNumberOne, { time=800, x=(answerSix.x ), y=(answerSix.y)})
print (“touch”)
return true
end
end
if correctAnswer == gameAnswer then
correctText.isVisible = True
end
–Incorrect Answer
if correctAnswer ~= gameAnswer then
print(“Bad Job”)
numberOfTries = numberOfTries + 1
end
My problem is, it doesn’t work when pressed my button that I set to be the right Answer. My button 1 is suppose set the Game Answer to 1 and I set the Correct Answer to 1 in the beginning. Can someone please help ?