[SOLVED] Director ERROR: Failed to execute new( params ) function on 'screen1'

Hey all.

I’ve run into a small error (as in it’s not stopping my app from running or anything) that says:

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

my error in the console:

Runtime error
…s\mroberti\DOCUME~1\CORONA~1\Sandbox\18\director.lua:1092: attempt to
call method ‘insert’ (a nil value)
stack traceback:
[C]: in function ‘insert’
…s\mroberti\DOCUME~1\CORONA~1\Sandbox\18\director.lua:1092: in functio
n 'changeScene’Runtime error: …s\mroberti\DOCUME~1\CORONA~1\Sandbox\18\directo
r.lua:1092: attempt to call method ‘insert’ (a nil value)
stack traceback:
[C]: in function ‘insert’
…s\mroberti\DOCUME~1\CORONA~1\Sandbox\18\director.lua:1092: in functio
n ‘changeScene’
…Users\mrob
Copyright © 2009-2011 A n s c a , I n c .
Version: 2.0.0
Build: 2011.591

Like I said, it goes to my scene just fine, and lets me switch to other scenes fine too. It only happens when I start the app.

Here’s my code:

display.setStatusBar( display.HiddenStatusBar ) -- HIDE STATUS BAR  
game = require("BeebeGames")  
debugText = display.newText("Debug text",100,30, native.systemFont, 12)  
-- LOAD DIRECTOR CLASS  
Director = require("director")  
require("helper")  
assetPath = "Assets/"   
UIPath = "Assets/Textures/UI/"  
  
-- LOAD PARTICLE LIB (DO \*NOT\* USE LOCAL HERE, SO YOU  
-- CAN ACCESS THE LIB FROM ALL YOUR LUA MODULES)  
Particles = require("lib\_particle\_candy")  
FXLibrary = require("lib\_particleEffects\_01")  
--FXLibrary.Initialize()  
-- CREATE A MAIN GROUP FOR DIRECTOR  
local MainGroup = display.newGroup()  
  
-- ADD THE GROUP FROM DIRECTOR CLASS  
MainGroup:insert(director.directorView)  
  
-- CHANGE SCENE WITHOUT EFFECTS  
Director:changeScene("screen1")  

I’d like to figure out why it’s doing this, not passing any params at all, just a plain ol’ scene change.

Any ideas? Appreciate any pointers!
[import]uid: 11636 topic_id: 14401 reply_id: 314401[/import]

I’m getting it too!

This is with the newly released 1.4
[import]uid: 19626 topic_id: 14401 reply_id: 53233[/import]

The lines from Director.lua (version 1.4) are as follows in the function changeScene


if currentStage[i].directorId == newScene
and currentStage[i].directorId ~= “main” then
nextScreen:insert( currentStage[i] )
end[/lua]

It is my thought that nextScreen either does not get set or is an object that is not a display Group which can have objects inserted into it.

cheers,

?:slight_smile:
[import]uid: 3826 topic_id: 14401 reply_id: 53272[/import]

@mroberti, put the code of scene1, please. [import]uid: 8556 topic_id: 14401 reply_id: 53275[/import]

[Edited for brevity…]

OK, forgive me, it’s 60 lines or so…

module(..., package.seeall)  
  
local screenW = display.contentWidth  
local screenH = display.contentHeight  
-- debugText = display.newText("Debug text",100,30, native.systemFont, 12) -- -- Runtime:removeEventListener( "enterFrame", monitorMem ) -- local monitorMem = function()  
 collectgarbage()  
 debugText.text = "MemUsage: " .. collectgarbage("count").."\nTexMem: "..system.getInfo( "textureMemoryUsed" ) / 1000000  
 debugText:toFront()  
end  
  
Runtime:addEventListener( "enterFrame", monitorMem )  
  
new = function ()  
 local gameBoard = display.newGroup()   
 -- Main Loop  
 local function main( event )  
  
 end  
 ---------------------------------------------------------------  
 -- FUNCTIONS USED IN THIS SCENE ONLY (LOCAL)  
 ---------------------------------------------------------------  
 local function nextScene(event)  
 Runtime:removeEventListener( "enterFrame", monitorMem )  
 Runtime:removeEventListener( "enterFrame", main )  
 event.target:removeEventListener("tap", nextScene)  
 Particles.CleanUp()  
 game.destroyAllObjects()  
 Director:changeScene("screen2","flip")   
 end  
  
 ------------------  
 -- MUST return a display.newGroup()  
 ------------------  
  
 local gameBoard = display.newGroup()  
 local BG = display.newImage("Assets/Textures/Backgrounds/1.jpg")   
 local Button = display.newImage("button.png", screenW\*.01, screenH-40)  
 Button:addEventListener("tap", nextScene)  
 local StatusText = display.newText( "SCENE 1 - TAP BUTTON TO SWITCH TO SCENE 2", screenW\*.1, screenH-30, native.systemFont, 16 )  
 StatusText:setTextColor( 255,255,255 )  
 -- CREATE AN EMITTER (NAME, SCREENW, SCREENH, ROTATION, ISVISIBLE, LOOP)  
 Particles.CreateEmitter("E1", screenW\*0.1, screenH\*0.5, 90, true, true)  
 gameBoard:insert(BG)  
 gameBoard:insert(Button)  
 gameBoard:insert(StatusText)  
 gameBoard:insert(Particles.GetEmitter("E1"))  
 -- FEED EMITTERS (EMITTER NAME, PARTICLE TYPE NAME, EMISSION RATE, DURATION, DELAY)  
 FXLibrary.Initialize()  
 FXLibrary.AttachRain("E1")  
 -- TRIGGER THE EMITTERS  
 Particles.StartEmitter("E1")  
 -- UPDATE PARTICLES FREQUENTLY  
 Particles.StartAutoUpdate()  
 Runtime:addEventListener( "enterFrame", main )  
 return gameBoard  
end  

It works fine with the director “template” file though:

module(..., package.seeall)  
  
--====================================================================--  
-- SCENE: [NAME]  
--====================================================================--  
  
--[[  
  
 - Version: [1.0]  
 - Made by: [name]  
 - Website: [url]  
 - Mail: [mail]  
  
\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
 - INFORMATION  
\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
  
 - [Your info here]  
  
--]]  
  
new = function ()  
  
 ------------------  
 -- Groups  
 ------------------  
  
 local localGroup = display.newGroup()  
  
 ------------------  
 -- Your code here  
 ------------------  
  
 --- CODE ---  
  
 ------------------  
 -- MUST return a display.newGroup()  
 ------------------  
  
 return localGroup  
  
end  

Any idea what I should be doing differently? :slight_smile: Appreciate the help Ricardo!
[import]uid: 11636 topic_id: 14401 reply_id: 53293[/import]

it just means that there is some error that occurs between line 18 - line 58.

Best way to test would be to comment out all of the code between these lines and run it line by line to see if it is fine, that way you can pinpoint/debug the line that causes the glitch.

The error can be the image not being found, it can be the runtime event handler, it can be the particle emitter breaking somewhere.
Have you included Particles in this module? I cannot see a reference to it anywhere…
cheers,

?:slight_smile: [import]uid: 3826 topic_id: 14401 reply_id: 53298[/import]

@jayantv Yeah! I included the particles reference in the ‘main.lua’ code I posted in the original post. All the memory is freed up from scene to scene too with no leaks, but like you recommended, I commented all the stuff out and started piece-by-piece reconstructing it. It’s choking out when I define a beebegames.lua object!

I figured it out.

Sometimes, it’s just returning to basics that lets you track it down.

Thanks mang!!!

-Mario [import]uid: 11636 topic_id: 14401 reply_id: 53299[/import]

WAIT A MINUTE!!!

It’s in my ParticleCandy library call!!!

@robmiracle You using Particle Candy?

When I call this function:

 -- Initialize our particles  
 local function InitializeParticles()  
 -- CREATE AN EMITTER (NAME, SCREENW, SCREENH, ROTATION, ISVISIBLE, LOOP)  
 Particles.CreateEmitter("E1", screenW\*0.1, screenH\*0.5, 90, true, true)  
 -- FEED EMITTERS (EMITTER NAME, PARTICLE TYPE NAME, EMISSION RATE, DURATION, DELAY)  
 FXLibrary.Initialize()  
 FXLibrary.AttachRain("E1")  
 -- TRIGGER THE EMITTERS  
 Particles.StartEmitter("E1")  
 -- UPDATE PARTICLES FREQUENTLY  
 Particles.StartAutoUpdate()  
 end  

it chokes out. So, I think I’ll address this over in the Particle Candy forum. :slight_smile:

[import]uid: 11636 topic_id: 14401 reply_id: 53305[/import]

got to be in particlecandy
ive been using 1.4 all day on a game thats 90% done with no problems

im using my own particle system [import]uid: 7911 topic_id: 14401 reply_id: 53307[/import]

I’m not using particle candy.

I did find a typo in my button code that should have had nothing to do with the error I got but once I fixed it, the problem went away.
[import]uid: 19626 topic_id: 14401 reply_id: 53379[/import]