Question about object instances

Hey there,

Im new to corona and im currently learning Lua, 

So this might sound like a silly question to you guys…

I wonder, if I have an object, say for example a box with physics, and now I want 30 more of that same boxes in the scene, how do I accomplish that? do I need to create 30 different boxes variables?

Can I create a prototype object and then ‘put’ its instances in the scene?

Roy.

You can build a function to spawn your boxes and have that function return the display object that was created.  I think most people would use a table to store each instance in.

local myBoxes = {}

for i = 1, 30 do

     myBoxes[i] = spawnBoxes()

end

or something like that.

Thank you for your reply :slight_smile:
Roy.

You can build a function to spawn your boxes and have that function return the display object that was created.  I think most people would use a table to store each instance in.

local myBoxes = {}

for i = 1, 30 do

     myBoxes[i] = spawnBoxes()

end

or something like that.

Thank you for your reply :slight_smile:
Roy.