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]