Composer Group Question

Lets say I have an object that is created multiple times to the same local variable.  Do I need to insert it into my group multiple times as well?   Or would I just load it once?  

Example:

Is this correct?

local menuBack = display.newRect( display.contentCenterX, display.contentCenterY, 280, 360 )

sceneGroup:insert( menuBack ) 

local menuBack = display.newRect( display.contentCenterX, display.contentCenterY, 100, 100)

sceneGroup:insert( menuBack )

Or is this correct?

local menuBack = display.newRect( display.contentCenterX, display.contentCenterY, 280, 360 )

sceneGroup:insert( menuBack ) 

local menuBack = display.newRect( display.contentCenterX, display.contentCenterY, 100, 100)
 

 

@warrenkuhl,

The first case will insert both objects in sceneGroup - So this is ‘correct

The second case will only store the first object in sceneGroup.

However, why not just do this:

display.newRect( sceneGroup, display.contentCenterX, display.contentCenterY, 280, 360 ) display.newRect( sceneGroup, display.contentCenterX, display.contentCenterY, 100, 100)

I know the basic examples show calls to some_display_group:insert( some_object), but it is so much better to just pass the group as the first argument.

RoamingGamer,

Thanks for the advice.  it definitely makes a lot more sense setting it up the way you suggest.

Appreciate your help!

Warren

Yes, The first case will store both the things in sceneGroup.

In Second case, Only first thing will be stored in sceneGroup.

@warrenkuhl,

The first case will insert both objects in sceneGroup - So this is ‘correct

The second case will only store the first object in sceneGroup.

However, why not just do this:

display.newRect( sceneGroup, display.contentCenterX, display.contentCenterY, 280, 360 ) display.newRect( sceneGroup, display.contentCenterX, display.contentCenterY, 100, 100)

I know the basic examples show calls to some_display_group:insert( some_object), but it is so much better to just pass the group as the first argument.

RoamingGamer,

Thanks for the advice.  it definitely makes a lot more sense setting it up the way you suggest.

Appreciate your help!

Warren

Yes, The first case will store both the things in sceneGroup.

In Second case, Only first thing will be stored in sceneGroup.