try this...
create a function in level.lua file which return the group and call the function from your file.
see the code below
level.lua
1
2
3
4
5
6
7
8
| module(..., package.seeall)
function new()
print("in new")
local localGroup = display.newGroup()
local txt = display.newText("from level",200,200,nil,25)
localGroup:insert(txt)
return localGroup
end |
I get this error when I try it:
Runtime error
/Users/Username/Desktop/myLevel.lua:6: attempt to index global 'localGroup' (a nil value)
I almost, almost, almost got it fixed now.
Just one little problem:
The old problem is gone (which is great! :D ) but now when i enter the myLevel a second time and have a function at the end which sets some layers toFront() i get a new error:
attempt to call method 'toFront' (a nil value)
Note: This only when I already have entered myLevel, gone to the mainmenu, levelmenu and then tries to get back to the myLevel again. It works if i delete the toFront() function.
Can you post the code please ?
Fixed it by making the function at the end a local function instead of a global function.
Thanks for all your help with the other things and sorry for being late with posting code.