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]