Hello…
I have a set of images that I can identify with an .id number
when I make a loop like this
local pNo = 1 for i = 1, 16 do p[i] = display.newImageRect ( sceneGroup, staff1[i], 106, 106) p[i].x = pin[pNo].x p[i].y = pin[pNo].y p[i]:scale (escaleX, escaleY) p[i].id = pNo --\<------- RIGHT HERE p[i]:addEventListener( "touch", listenerOne ) pNo = pNo + 1 end
This is in a HORIZONTAL way one ROW
QUESTION
If I have a table like a board.
Horizontal and vertical
I use for i and for j
How do I add the event listener and the .id to the <for i> and the <for j>?
So each of the squares has a unique .id number
local tiles = {} function createBoard() for i = 1, 4 do for j = 1, 4 do tiles[i] = display.newRect(800, 800, 40, 40) tiles[i]:setFillColor(0, 0, 1) tiles[i].x = 50\*(i-1) tiles[i].y = 50\*(j-1) end end end createBoard()
Thanks for all your help
Victor