I have this function and it creates a simple board of rectangles.
But i want to be able to detect each of them.
So I can add a function to each of them
function whichOne(event) if event.phase == "began" then if titles.numberID == 10 then print("This is box number 10") end end end local titles = {} function createBoard() for i = 1, 10 do for j = 1, 6 do local titles = display.newRect( sceneGroup, 0, 0, 40, 40 ) titles[i] = titles titles.x = 60 \* i titles.y = 60 \* j titles.numberID = (i - 1) \* 6 + j titles:addEventListener( "touch", whichOne) end end end createBoard()
the createBoard() function is great, works fine
but the whichOne(event) function I have the idea
but that is the one function I don’t know how to make it work.
I tried with event.target but I didn’t get it.
If I have 36 boxes I want to loop to all of them and print
each number on the terminal…
Thanks for your help
Victor