Hi there,
I’m creating a simple 2D puzzle game as a means to learn Corona.
The game involves a 10x10 grid of individual rectangle objects which I have created dynamically based on a table (that has other value in it such as .x, .y, ‘name’.
One value in the table is a unique text string such as [name= “object27”] - there are 100, one each for each of the rectangle display objects I subsequently create.
I retrieve this name value and use it to create each of the 100 display objects as follows:
for i = 1, (numOfColumns*numOfRows) do
local object = table[i].name – get string to use to create object name e.g. “object27”
object = display.newRect( x, y, 80, 80 )
objectGroup:insert( object )
Now I can
- draw all 100 rectangles
- retrieve objectGroup.numChildren (is 100 as expected)
- print ("object name is " … object) ( shows “object name is object27” etc etc)
But when I try to address any of the objects individually (e.g. to change it’s .x value) the console tells me…Runtime error…attempt to index global ‘object27’
I cant see where I am going wrong. Any help appreciated.
[import]uid: 191070 topic_id: 35290 reply_id: 335290[/import]