Hi Everyone…
I have 1 image
bgOff = display.newImageRect( sceneGroup, "images/sBgOff.png", 430, 430 ) bgOff.x = display.contentCenterX - separacionX bgOff.y = display.contentCenterY bgOff:scale (.7, .7) bgOff.anchorX = 1 bgOff.anchorY = 1 bgOff.isVisible = true
I add 1 function “touch”
function bgOff:touch( event ) if event.phase == "began" then quitaFlechita() bgOn.isVisible = true bgOff.isVisible = false bringBgs() return true end end bgOff:addEventListener( "touch", bgOff )
WORKS FINE!
the problem I have is when I want to use the “loop” – for i …
Like this I have 7 images in 1 loop, they work great
local numerito = 1 for i = 1, 7 do nail[i] = display.newImageRect( sceneGroup, "images/nail" .. numerito .. ".png", 250, 188 ) nail[i].x = - 100 nail[i].y = -30 + i\*120 nail[i]:scale (.6, .6) nail[i].isVisible = true numerito = numerito + 1 end
Now… How do I add an event listener to all 7 of them, so I can do something different on each of them
I did this and it won’t work
function nail[i]:touch( event ) if event.phase == "began" then transition.to(negrito, {time=100, x=100, y=nail[1].y}) return true end end nail[i]:addEventListener( "touch", nail[i] )
even if I change … nail[i] for nail[1]
Please I need your help, thank you very much for everything you do to help me
and all of us in the forum, thanks.
Victor