i see that you are trying to build something in your class module then take that function and call it from your scene module, the problem you are having is with inserting the objects in your class module if i am not mistaken.
you should be able to make a group at the start of you function then return the group at the end, then when you call the function you can also insert it into a group in your scene module. Also i did some modifications since the module class module is not called by director and is just an external module.
[lua]–theClass module
–Create a table to house any external module functions
–you want to be accessed from the outside
local classTable = { }
local theGroup = display.newGroup ( )
local function theFunc ()
local theGroup = display.newGroup ( )
local back = display.newImage(“background.png”)
back:setReferencePoint(display.TopLeftReferencePoint)
back.x = 200
back.y = 200
theGroup:insert(back)
return theGroup
end
classTable.theFunc = theFunc
–Return the module function table at the end of the module
return classTable[/lua]
then you just call the function from the module you want and insert it into the scene
[lua]–fakeScene.lua
–module call for director
module(…,package.seeall)
require(“cleangroup”)
local theClass = require(“theClass”)
local director = require(“director”)
–house all of your scene into the new function
function new()
local localGroup = display.newGroup ( )
local back = display.newImage( “background.png” )
back:setReferencePoint(display.TopLeftReferencePoint)
back.x = 100
back.y = 100
localGroup:insert (back)
local function clicked(event)
if(event.phase == “ended”) then
director:changeScene(“gameScene”)
end
end
back:addEventListener(“touch”, clicked)
local theFunc = theClass.theFunc
–since you returned the group from the class module you can --insert into the local group just like any other display object
localGroup: insert (theFunc)
theFunc()
end[/lua]
didnt test it but it should work, just let me know, i changed the way you had the module set up by using a table so you dont have to worry about the module (…, package.seeall) for your module, still have to use it for director. also You need to include your whole scene in the function new() area for director to run it when it changes scene [import]uid: 126161 topic_id: 22780 reply_id: 91012[/import]