Hey guys got a quick syntax question. So lets say i create 4 game objects like so…
[lua]local goblin_1 = display.newImageRect( “goblin.png”, 50, 50 )
goblin_1.x = 734
goblin_1.y = 255
physics.addBody( goblin_1, { density=1, friction=0.3, bounce=0.2 } )
local goblin_2 = display.newImageRect( “goblin.png”, 50, 50 )
goblin_2.x = 1054
goblin_2.y = 255
physics.addBody( goblin_2, { density=1, friction=0.3, bounce=0.2 } )
local goblin_3 = display.newImageRect( “goblin.png”, 50, 50 )
goblin_3.x = 1072
goblin_3.y = 205
physics.addBody( goblin_3, { density=1, friction=0.3, bounce=0.2 } )
local goblin_4 = display.newImageRect( “goblin.png”, 50, 50 )
goblin_4.x = 1106
goblin_4.y = 254
physics.addBody( goblin_4, { density=1, friction=0.3, bounce=0.2 } )[/lua]
now i want to insert all 4 of these objects into a display group, normally i would do it by hand, im trying to figure out how to use a FOR loop to do so… what i have right now is
[lua]for i = 1, 4 do
M.masterBlockGroup:insert(goblin_i)
end[/lua]
What would be the correct syntax to accomplish this? thanks!
[import]uid: 19620 topic_id: 21882 reply_id: 321882[/import]
[import]uid: 52491 topic_id: 21882 reply_id: 86999[/import]