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

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

1
2
3
4
5
6
7
8
9
function new()
   mainGroup = display.newGroup()
   something = display.newGroup()
 
   mainGroup:insert(something) -- something group is now inside the mainGroup which director uses
 
 
   return mainGroup
end

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

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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>
views:1386 update:2011/10/12 18:33:00
corona forums © 2003-2011