Hi. I’m a newbie to Corona and the Lua Programming Language.
I’m creating a grid based application, a feature of which, displays a grid of images.
I want to assign a unique numeral id for each image in the grid by assigning each element a property, e.g. myImage.ID = counter
I know I need a counter but I cannot seem how to do this. I can get it to display a count for the rows or columns but not each cell.
Its probably something simple but I cannot seem to figure it out.
Any help would be greatly appreciated.
local chipWidth = 150 local chipHeight = 150 local colSpace = 0 local rowSpace = 0 local numCols = 25 local numRows = 25 gd = {} --table for col = 1, numCols do gd[col] = {} for row = 1, numRows do local chip = display.newImageRect("grassIco.png", chipWidth, chipHeight) chip.x = col \* chip.width - chip.width/2 chip.y = row \* chip.height - chip.height/2 chip.gridPos = {x=col, y=row} chip.isSelected = false chip.state = "grass" chip.id = "" --\<\<\<\< Need to populate a UNIQUE ID HERE using a counter value. chip:addEventListener("tap", chipTapped) gd[col][row] = chip local myText = display.newText(row, chip.x, chip.y, native.systemFontBold, 36) group:insert(chip) group:insert(myText) end end