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

When i opened my app on my device i go this message, “Director Error: Failed to execute new( params ) function on ‘menu’.”

My menu file:
[lua]module(…, package.seeall)

new = function ( params )


– Imports

local ui = require ( “ui” )


– Groups

local localGroup = display.newGroup()


– Audio


– Display Objects

local background = display.newImage( “background.png”)
localGroup:insert( background )

local title = display.newText( “Penguin Control”, 0, 0, native.systemFontBold, 32 )
localGroup:insert( title )


– Image

local bubble = display.newImage( “bubble1.png” )
localGroup:insert( bubble )

local penguin = display.newImage( “penguin.png” )
localGroup:insert( penguin )

local btParameters = display.newText( “Start”, 0, 0, native.systemFontBold, 32 )
localGroup:insert( btParameters )

local options = display.newText( “Options”, 0, 0, native.systemFontBold, 32 )
localGroup:insert( options )

– Listener

local btParameterst = function ( event )
if event.phase == “ended” then
director:changeScene(“level1”)
end
end

local function pressOptions (event)
if event.phase == “ended” then
director:changeScene (“options”)
end
end

options:addEventListener (“touch”, pressOptions)

–====================================================================–
– INITIALIZE
–====================================================================–

local initVars = function ()


– Inserts


– Positions

title.x = 225
title.y = 20

btParameters.x = 225
btParameters.y = 150

bubble.x = 225
bubble.y = 190

penguin.x = 45
penguin.y = 265

options.x = 225
options.y = 190


– Colors

title:setTextColor( 255,255,255 )

btParameters:setTextColor( 300,455,255 )

options:setTextColor( 300,455,255 )


– Listeners

btParameters:addEventListener ( “touch” , btParameterst )

end


– Initiate variables

initVars()


– MUST return a display.newGroup()

return localGroup

end
[import]uid: 132369 topic_id: 27104 reply_id: 327104[/import]

Hey,

I only looked at the code for a matter of seconds…
I didn’t see anything that would create that error but just comment out a couple lines at a time and see if it works, just keep commenting the lines out until you find the error then just look it over to see if anything stands out. Just ask if you need more help.
[import]uid: 113909 topic_id: 27104 reply_id: 110033[/import]

The director error you are getting is a general error, it is an error you will get any time you try to switch scenes to a scene that has an error. Basically you created a function called “new” that director calls when it loads a new scene and all director is telling you is something is wrong in the new function of that scene.

A couple of questions:
1.) does it work in the simulator? and you are having a problem on the device?

2.) i see there are display.newImage there, are all of the image names correct? are the images in the main root directory?(i.e. the same director as your main.lua) i ask this because the image names are NOT case sensitive in the simulator but they ARE case sensitive on the device.

3.) lastly you should get an error in the terminal/command window that will show u which line the error is on, with director this is not always true sometimes it just gives you the new function error but most of the time it should tell you what line in menu the error is on.

the code looks fine, my guess would be something with the images. you should have “background.png”, “penguin.png”, and a “bubble1.png” images all in the same directory as your main.lua according to your code. [import]uid: 126161 topic_id: 27104 reply_id: 110037[/import]

Thank you for commenting. I checked all the images and the names are correct. My game does run on the simulator perfectly without any errors. And also there are no errors in the terminal at all. I don’t know why else this is not working. Also all of the images are in the same folder as my main.lua and the test of the other files. [import]uid: 132369 topic_id: 27104 reply_id: 110041[/import]

I think i know the issue. In lines 42, 51, and 110. In line 42 my start button is called “btParameters”, but in line 51 its called “btParameterst”. There is a “T” at the end of btParameters in line 51. In line 110 it is btParameters:addEventListener ( “touch” , btParameterst ) for the listener. When i try to change it, the terminal says… But i don’t know why

[code]

Runtime error
/Users/Mazensalih/Documents/Penguin/director.lua:1039: attempt to call method ‘insert’ (a nil value)
stack traceback:
[C]: in function ‘insert’
/Users/Mazensalih/Documents/Penguin/director.lua:1039: in function ‘changeScene’
/Users/Mazensalih/Documents/Penguin/main.lua:9: in function ‘main’
/Users/Mazensalih/Documents/Penguin/main.lua:13: in main chunk
Runtime error: /Users/Mazensalih/Documents/Penguin/director.lua:1039: attempt to call method ‘insert’ (a nil value)
stack traceback:
[C]: in function ‘insert’
/Users/Mazensalih/Documents/Penguin/director.lua:1039: in function ‘changeScene’
/Users/Mazensalih/Documents/Penguin/main.lua:9: in function ‘main’
/Users/Mazensalih/Documents/Penguin/main.lua:13: in main chunk


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

/Users/Mazensalih/Documents/Penguin/menu.lua:85: attempt to index upvalue ‘btParameters’ (a function value)

[import]uid: 132369 topic_id: 27104 reply_id: 110043[/import]

So the images names including caps are correct? penguin.png is different from Penguin.png but it will work in the simulator but not on the device. Also this hold true for the director scenes, Level1 and level1 are different but it will work either way in the simulator but the device is case sensitive so you will get an error.

If this is all correct then you have no choice but to start debugging by commenting out lines and see what the problem is. [import]uid: 126161 topic_id: 27104 reply_id: 110044[/import]

Thats because btParameterst is a function and btParameters is a text object so all of that is correct. Basically whats going on is the btParameters text object is being created then when you took the T off of btParameterst the program overwrote the btParameters text object and made it a function then the initVars function tried to change the position of a function which you can’t do since it is not a display object. So the coding is correct to that degree, i am still leaning towards a case sensitive issue. [import]uid: 126161 topic_id: 27104 reply_id: 110048[/import]

Moved to director class forum [import]uid: 84637 topic_id: 27104 reply_id: 110305[/import]