Director ERROR: Failed to execute new( params ) function on 'menu'

Hey everyone,

Whenever I run my game in the corona simulator I get the following error message:

[code]Runtime error
C:\Users\Samuel\Desktop\lasttime\director.lua:1092: attempt to call meth
od ‘insert’ (a nil value)
stack traceback:
[C]: in function ‘insert’
C:\Users\Samuel\Desktop\lasttime\director.lua:1092: in function ‘changeS
cene’
C:\Users\Samuel\DeRuntime error: C:\Users\Samuel\Desktop\lasttime\direct
or.lua:1092: attempt to call method ‘insert’ (a nil value)
stack traceback:
[C]: in function ‘insert’
C:\Users\Samuel\Desktop\lasttime\director.lua:1092: in function ‘changeS
cene’
C:\Users\Samuel\Desktop\lasttime\

Director ERROR: Failed to execute new( params ) function on ‘menu’.

assertion failed!
-----------------------[/code]

My main.lua file:

[code]_W = display.contentWidth
_H = display.contentHeight

local director = require(“director”)

local mainGroup = display.newGroup()
local function main()

mainGroup:insert(director.directorView)
director:changeScene(“menu”)

return true
end

main()[/code]

My menu.lua file:

[code]module(…, package.seeall)

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

–HIDE STATUS BAR
display.setStatusBar(display.HiddenStatusBar)

–INSERT BACKGROUND
local background = display.newImage(“graphics/wall.png”, _W, _H)
background.x = _W/2;
background.y = _H/2;

–INSERT TITLE
local title = display.newImage(“graphics/title.png”, 50, 132)
title.x = _W/2;
title.y = title.height;

–INSERT REDBALLOON
local play_btn = display.newImage(“graphics/redballoon.png”, 50, 75)
play_btn.x = _W/2;
play_btn.y = _H/2;
play_btn.scene = “game”
play_btn:addEventListener(“touch”, changeScene)

–INSERT BLACKBALLOON
local credits_btn = display.newImage(“graphics/blackballoon.png”, 75, 75)
credits_btn.x = _W/2;
credits_btn.y = _H2/2;
play_btn.scene = “credits”
credits_btn:addEventListener(“touch”, changeScene)

–INSERT IMAGES INTO GROUP
localGroup:insert(background)
localGroup:insert(title)
localGroup:insert(play_btn)
localGroup:insert(credits_btn)

–CHANGESCENE FUNCTION
function changeScene(e)
if(e.phase == “ended”) then
director:changeScene(e.target.scene)
end
end

return localGroup
end[/code]

Thanks for your help! [import]uid: 90223 topic_id: 15236 reply_id: 315236[/import]

You may want to try moving the changescene function above the “insert redballoon”. [import]uid: 67217 topic_id: 15236 reply_id: 56440[/import]

This was was solved not messing around with the director file so much…

Thanks for your help anyway :slight_smile: [import]uid: 90223 topic_id: 15236 reply_id: 58591[/import]