combining two objects from two different modules

Hi,

is there a way to merge two objects into one group, when each object is located and initiated from a different module?

I tried making them global but I still get errors (I want the two object to be as one so they could both move together without any lags).

I’d prefer not creating them both in the same module because Its a lot of code and i’d rather split it between the two of them…

Hi Dan,

You might consider passing a display group to the module(s) and inserting the objects into it. I outlined a method of doing this here:

http://forums.coronalabs.com/topic/29939-removing-display-objects-from-memory-without-inserting-in-selfview/#entry161099

Brent

tried doing that in another fashion, because I don’t need to remove any of them, and that code was a bit confusing…

I made a function in the scene I need them both to appear in - 

myGroup=display.newGroup()
myGroup.x=display.contentWidth/2
myGroup.y=display.contentHeight/2

function insertGroup(obj)
myGroup:insert(obj)
obj.x=myGroup.x
obj.y=myGroup.y
end

But the objects do not appear anywhere on screen…

tried giving all the children the same coordinates but still nothing

Nvm managed to fix that, thanks

Hi Dan,

You might consider passing a display group to the module(s) and inserting the objects into it. I outlined a method of doing this here:

http://forums.coronalabs.com/topic/29939-removing-display-objects-from-memory-without-inserting-in-selfview/#entry161099

Brent

tried doing that in another fashion, because I don’t need to remove any of them, and that code was a bit confusing…

I made a function in the scene I need them both to appear in - 

myGroup=display.newGroup()
myGroup.x=display.contentWidth/2
myGroup.y=display.contentHeight/2

function insertGroup(obj)
myGroup:insert(obj)
obj.x=myGroup.x
obj.y=myGroup.y
end

But the objects do not appear anywhere on screen…

tried giving all the children the same coordinates but still nothing

Nvm managed to fix that, thanks