hi,
When i begin i have a lot of difficulties to set a correctly grid. With this snippet, no problem.
Have a good time.
--here enter your value local row = 7 --number of element in x local line = 10 --number of element in y local space = 10 --space between each cell local spaceLeftAndRight =30 --space between the left side and the first cell --the code -------------------------------------------------------------------------------- local grid = {} local imx=(display.contentWidth-((row-1)\*space+(spaceLeftAndRight\*2)))/row local imy=(display.contentWidth-((row-1)\*space+(spaceLeftAndRight\*2)))/row local spacetop=(display.contentHeight-((space\*(line-1))+(imx\*line)))/2 --calculate space bottom and top for i = 1, line do grid[i] = {}; for k = 1, row do grid[i][k] = display.newRect(0,0,imx,imy) grid[i][k].yScale=1 grid[i][k].xScale=1 grid[i][k].alpha = 1 grid[i][k].x = (k - 1) \* imx+ imx\*.5 + (k-1)\*space + spaceLeftAndRight grid[i][k].y = (i - 1) \* imx+ imx\*.5 + (i-1)\*space + spacetop end end
edited