Hi all,
I need help to compare an order, how i can do that? I mean, I have a list of images with a listener on each one, so when I tap over the image, a check appear, but i need to make them check in a order. Any tip?
Basically this is a list of images that shows differents months and the user has to select the right order, example (first clic on January, second on Febrary, third on March and go on…) and if the user clic first on Febrary and then on March or January, automatically resets so he can start over and do it in the right order.
This is my code:
local checkmano = display.newImageRect("images/check.png", 228, 179); checkmano.x = 200; checkmano.y = 145; checkmano:scale (.2,.2) checkmano.isVisible=false myGroupjuegos:insert( checkmano ) local checkmano1 = display.newImageRect("images/check.png", 228, 179); checkmano1.x = -30; checkmano1.y = 145; checkmano1:scale (.2,.2) checkmano1.isVisible=false myGroupjuegos:insert( checkmano1 ) local checkmano2 = display.newImageRect("images/check.png", 228, 179); checkmano2.x = 670; checkmano2.y = 145; checkmano2:scale (.2,.2) checkmano2.isVisible=false myGroupjuegos:insert( checkmano2 ) --January function imagenabuscar1:touch( event ) if event.phase == "began" then checkmano4.isVisible=true print ("Enero") end return true end imagenabuscar1:addEventListener( "touch", imagenabuscar1 ) --Febrary function imagenabuscar2:touch( event ) if event.phase == "began" then checkmano.isVisible=true print ("Febrero") end return true end imagenabuscar2:addEventListener( "touch", imagenabuscar2 ) --March function imagenabuscar3:touch( event ) if event.phase == "began" then checkmano5.isVisible=true print ("Marzo") end return true end imagenabuscar3:addEventListener( "touch", imagenabuscar3 )
local function restore()
checkmano.isVisible=false
checkmano1.isVisible=false
checkmano2.isVisible=false
checkmano3.isVisible=false
end
---------------this is my function but i don’t know how to do this-----------------
function compruebaelorden()
if checkmano4.isVisible==true and checkmano.isVisible==true and checkmano5.isVisible==true and checkmano2.isVisible==true then
print (“Order ok!”)
elseif checkmano4.isVisible==true or checkmano.isVisible==true or checkmano5.isVisible==true or checkmano2.isVisible==true then
print (“Wrong order”)
restore()
end
end
compruebaelorden()
Thanks for the help, i hope you understand what i’m trying to do and my english also