Inserting images into a group

Hi there,

I am writing a game that will have a number of clouds floating across the screen colliding with other objects. And I just wanted which of the two methods below is better for inserting the images into a group?

[code]

local gameLayer = newGroup()

Use a table

local clouds {
cloud1 = display.newImage(‘images/cloud.png’),
cloud2 = display.newImage(‘images/cloud.png’),
cloud3 = display.newImage(‘images/cloud.png’)
}

gameLayer.insert(clouds)
or is it better to insert each image individually

local gameLayer = newGroup()

local cloud1 = display.newImage(‘images/cloud.png’)
local cloud2 = display.newImage(‘images/cloud.png’)
local cloud3 = display.newImage(‘images/cloud.png’)

gameLayer:insert(cloud1)
gameLayer:insert(cloud2)
gameLayer:insert(cloud3)
[/code] [import]uid: 167310 topic_id: 30525 reply_id: 330525[/import]

You also have the option to insert the image on creation. I personal have not run any speed tests on this.

[lua]
cloud1 = display.newImage(gameLayer, ‘images/cloud.png’)[/lua] [import]uid: 7177 topic_id: 30525 reply_id: 122306[/import]

Thanks for the tip I’ve tried your suggestion as well which works fine I suppose there is no ideal way to insert an image etc just what works best for you? [import]uid: 167310 topic_id: 30525 reply_id: 122488[/import]

You also have the option to insert the image on creation. I personal have not run any speed tests on this.

[lua]
cloud1 = display.newImage(gameLayer, ‘images/cloud.png’)[/lua] [import]uid: 7177 topic_id: 30525 reply_id: 122306[/import]

Thanks for the tip I’ve tried your suggestion as well which works fine I suppose there is no ideal way to insert an image etc just what works best for you? [import]uid: 167310 topic_id: 30525 reply_id: 122488[/import]