director class with moduler code! grouping issue

Hi guys
I am using director class for my new project and its really nice class to work with. But i am facing little problem while grouping the objects from external modules…
I am posting my sample code so it will give you some idea, what i am trying to achieve.

Here in my case ship is getting spawn correctly without any problem but i dont know how to add this object into “localGroup” of level01.
(I am using modular code because i am planing to have approx 100 levels in my game and i dont want to write the code for each object in every level…)

Level 01 Files Code :

[code]
module(…, package.seeall)

function new()
local localGroup = display.newGroup()

local background = display.newImage(“images/background01.jpg”)
background:setReferencePoint(display.CenterReferencePoint)
background.x = _W /2 ; background.y = _H /2
localGroup:insert(background)

ship.spawnship({x = _W /2 , y = _H /2 + 150})–HOW TO ADD THIS SPAWNED OBJECT INTO LOCAL GROUP???

return localGroup
end
And Here is the SHIP files code:
module(…, package.seeall)
function spawnship()

ship = display.newImage(“images/ship.png”)
ship:setReferencePoint(display.CenterReferencePoint)
ship.x = params.x
ship.y = params.y
ship.name = “ship”

localGroup:insert(ship) – Not working

end
Let me know if you guys have any solution or workaround.
Thanks in advance [import]uid: 83799 topic_id: 27438 reply_id: 327438[/import]

Hey guys i found the solution for this… Here is the code
I just did two things

  1. Created parameter for group, just like i have created for x and y coordinates.

  2. Added one more parameter call for a group on function call…

Its working well now… i hope this is one of the correct way and if its not please guide me…

Thanks and regards,
Siddhesh.Meher

[code]
module(…, package.seeall)

function new()
local localGroup = display.newGroup()

local background = display.newImage(“images/background01.jpg”)
background:setReferencePoint(display.CenterReferencePoint)
background.x = _W /2 ; background.y = _H /2
localGroup:insert(background)
–Look for changes in this line
ship.spawnship({x = _W /2 , y = _H /2 + 150 , group = localGroup })-- i have just added one more parameter call…

return localGroup
end

And Here is the SHIP files code:

module(…, package.seeall)
function spawnship()

ship = display.newImage(“images/ship.png”)
ship:setReferencePoint(display.CenterReferencePoint)
ship.x = params.x
ship.y = params.y
ship.name = “ship”
–Here are some additional lines
ship.group = params.group
ship.group:insert(ship)

end [import]uid: 83799 topic_id: 27438 reply_id: 111556[/import]