nested group using with Director class

hi good morning,

I’m new with corona and game development.
I have try to develop my game with corona. I have completed few state but when I integrate it to director it come up some problem with those nested group.

I wouldl like to know can we use nested group in director class. Nested group image have no problem with individual stage.
Anyone experience this before can share with me.

Thanks in advance.

unit303 [import]uid: 36121 topic_id: 11164 reply_id: 311164[/import]

You just have to insert each group into the group your new() function returns:

[lua]function new()
mainGroup = display.newGroup()
something = display.newGroup()

mainGroup:insert(something) – something group is now inside the mainGroup which director uses
return mainGroup
end[/lua]

– Chris [import]uid: 33866 topic_id: 11164 reply_id: 40510[/import]

Dear Chris,

Thanks for your help.

My set up is same but it doesn’t work.

I using “movieclip.newAnim” to display image and object.xReference & yReference mark co-ordination.

Is this cause the problem?

unit303 [import]uid: 36121 topic_id: 11164 reply_id: 40537[/import]

hi,
I post my code here. Hope someone can help me. The position was not working properly after integrated in director class. The nested group keep having problem. Do I use the “local” correctly.

Because I saw some sample using

A)
local localGroup = display.newGroup();
but some without local at beginning.
localGroup = display.newGroup();

B)
some nested group specially subgroup are not using local for all object. ONLY using “local” at those object with localGroup. How should we implement on this.
my code is here, work fine when without using director class, I think my implementation have problem.

[code]

local function clean ( event )
print(“2 cleaned”)
end

function new()

local H = display.contentHeight;
local W = display.contentWidth;

display.setStatusBar(display.HiddenStatusBar);

local movieclip = require(“movieclip”)

localGroup = display.newGroup();
Reel = display.newGroup();
Compartment = display.newGroup();

local background = display.newImageRect(“1.png”, 640, 960)
background:setReferencePoint(display.CenterReferencePoint);
background.x = W/2;
background.y = H/2;
localGroup:insert(background);
local tree = movieclip.newAnim{ “tree1.png”, “tree2.png”, “tree3.png”}
tree:play{ startFrame=1, endFrame=1, loop=1, remove=false }
tree:setReferencePoint(display.CenterReferencePoint);
tree.x = 380
tree.y = 400
localGroup:insert(tree)
local Reel = display.newImageRect(“reel.png”, 120, 120)
Reel:setReferencePoint(display.CenterReferencePoint);
Reel.x = 360; Reel.y = 680
Reel.rotation = 0;
localGroup:insert(Reel)

Compartment = display.newImageRect(“comp.png”, 100, 100)
Compartment:setReferencePoint(display.CenterReferencePoint);
Compartment.x = 200;
Compartment.xReference = -200;
Compartment.rotation = 60;
Reel:insert(Compartment)

car = display.newImageRect(“car1.png”, 80, 80)
car = movieclip.newAnim{ “car1.png”, “car2.png”, “car3.png”}
car:play{ startFrame=1, endFrame=1, loop=1, remove=false }
car:setReferencePoint(display.CenterReferencePoint);
–car.x = 0; car.y = 0;
car.rotation = 90;
car.count = 0;
Compartment:insert(car);

return localGroup

end

[code]
[import]uid: 36121 topic_id: 11164 reply_id: 40547[/import]