[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 (C) 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:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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'm getting it too!

This is with the newly released 1.4

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

1090
1091
1092
1093
   if currentStage[i].directorId == newScene 
      and currentStage[i].directorId ~= "main" then                     
        nextScreen:insert( currentStage[i] )
   end

@mroberti, put the code of scene1, please.

[Edited for brevity...]

OK, forgive me, it's 60 lines or so...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
module(..., package.seeall)
 
local screenW = display.contentWidth
local screenH = display.contentHeight
 
 
-- debugText = display.newText("Debug text",100,30, native.systemFont, 12) -- <-- Put this in main.lua
--      Runtime:removeEventListener( "enterFrame", monitorMem ) -- <-- Put this in your destroy!
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 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,

?:)

@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

WAIT A MINUTE!!!

It's in my ParticleCandy library call!!!

@robmiracle You using Particle Candy?

When I call this function:

1
2
3
4
5
6
7
8
9
10
11
12
        -- 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

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

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.

views:20009 update:2011/10/12 18:33:00
corona forums © 2003-2011