Noob problem with timer in sotryboard

Hello!

Here´s the deal, I´am trying to do an intro for my app by first loading my intro.lua with 2 timers in it.

1 is for the intro picture to pop up from the black screen, 1 is ofc for changeing to meny.

The “simple” function works with the “isvisible” but when i try the gotoscene it just does not work.

It says something like "bad argument… insert… proxy expected, got nil.

It only works if i do a :

local function forrasidan( self, event )

if event.phase == “ended” then
storyboard.gotoScene( “bild2”, “fade”, 500)

return true
end
end

then it works. Why?

This is how it looks like.

[code] local storyboard = require( “storyboard” )
local scene = storyboard.newScene()
--------------FUNKTIONER---------------------------------------

local function bild (event)
intro.isVisible=true
audio.play(plingSnd)

return true
end

local function bytameny (event)
storyboard.gotoScene( “menu”, “fade”, 500)
return true
end
– Called when the scene’s view does not exist:
function scene:createScene( event )
local Group0 = self.view

plingSnd = audio.loadSound(“pling.mp3”)
intro = display.newImage(“intro.jpg”)
Group0:insert (intro)
intro.isVisible=false
print( “\n1: createScene event”)
end

– Called immediately after scene has moved onscreen:
function scene:enterScene( event )
local Group0 = self.view

local t1=timer.performWithDelay(1500,bild,1)
local t2=timer.performWithDelay(4400,bytameny,1)
print( “1: enterScene event” )

end

[code]
Thank you lads! [import]uid: 197493 topic_id: 34655 reply_id: 334655[/import]

One thing I see is there’s no return scene at the end of your code [import]uid: 7911 topic_id: 34655 reply_id: 137713[/import]

No it is at the bottom in the real code, I only posted the part where I know there´s a problem.

Should I post the whole part anyway?

Thank you! [import]uid: 197493 topic_id: 34655 reply_id: 137768[/import]

Do you have an error in your menu.lua?

Can you post the error message you’re getting including the whole stack trace with line numbers and such?

[import]uid: 199310 topic_id: 34655 reply_id: 137786[/import]

http://www.ladda-upp.se/bilder/ljcsqckhedpwj/ [import]uid: 197493 topic_id: 34655 reply_id: 138059[/import]

Can you post the code for intro.lua? Also I’d like to see the exitScene() function for the above module.
[import]uid: 199310 topic_id: 34655 reply_id: 138184[/import]

One thing I see is there’s no return scene at the end of your code [import]uid: 7911 topic_id: 34655 reply_id: 137713[/import]

No it is at the bottom in the real code, I only posted the part where I know there´s a problem.

Should I post the whole part anyway?

Thank you! [import]uid: 197493 topic_id: 34655 reply_id: 137768[/import]

Do you have an error in your menu.lua?

Can you post the error message you’re getting including the whole stack trace with line numbers and such?

[import]uid: 199310 topic_id: 34655 reply_id: 137786[/import]

I feel bad for asking this, that is the code for bild2?

[import]uid: 199310 topic_id: 34655 reply_id: 138377[/import]

[code]
local storyboard = require( “storyboard” )
local scene = storyboard.newScene()
--------------FUNKTIONER---------------------------------------

local function bild (event)
intro.isVisible=true
audio.play(plingSnd)

return true
end

local function bytameny (event)
print(“helvete!”)
storyboard.gotoScene( “bild2”, “zoomInOutFade”, 1000)

return true
end

local t2=timer.performWithDelay(4400,bytameny,1)
– Called when the scene’s view does not exist:
function scene:createScene( event )
local Group0 = self.view
audio.setVolume( 0.1)
plingSnd = audio.loadSound(“pling.mp3”)
intro = display.newImage(“intro.jpg”)
Group0:insert (intro)
intro.isVisible=false

print( “\n1: createScene event”)

end
– Called immediately after scene has moved onscreen:
function scene:enterScene( event )
local Group0 = self.view

local t1=timer.performWithDelay(1500,bild,1)

print( “1: enterScene event” )

end
– Called when scene is about to move offscreen:
function scene:exitScene( event )
local Group0 = self.view
print( “1: exitScene event” )
storyboard.purgeScene( “intro” )

end
– Called prior to the removal of scene’s “view” (display group)
function scene:destroyScene( event )
local Group0 = self.view
print( “((destroying intro´s view))” )

end

– Called AFTER scene has finished moving offscreen:
function scene:didExitScene( event )
local Group0 = self.view
audio.stop()
audio.dispose( )
storyboard.removeScene(“intro”)

end


– END OF YOUR IMPLEMENTATION

– “createScene” event is dispatched if scene’s view does not exist
scene:addEventListener( “createScene”, scene )

– “enterScene” event is dispatched whenever scene transition has finished
scene:addEventListener( “enterScene”, scene )

– “exitScene” event is dispatched before next scene’s transition begins
scene:addEventListener( “exitScene”, scene )

– “destroyScene” event is dispatched before view is unloaded, which can be
– automatically unloaded in low memory situations, or explicitly via a call to
– storyboard.purgeScene() or storyboard.removeScene().
scene:addEventListener( “destroyScene”, scene )
– “didExitScene” event is dispatched after scene has finished transitioning out
scene:addEventListener( “didExitScene”, scene )


return scene

[code] [import]uid: 197493 topic_id: 34655 reply_id: 138275[/import]

Im so sorry! haha.

Dont know how i could cta + a the wrong lua?

It´s fixed now. :slight_smile: Look up again. [import]uid: 197493 topic_id: 34655 reply_id: 138409[/import]

Sorry again. Looks like I’m having a bad typing night. Can you post the code for bild2.lua?

[import]uid: 199310 topic_id: 34655 reply_id: 138414[/import]

[code]
– Project: main.lua
– Description:

– Version: 1.0
– Managed with http://CoronaProjectManager.com

– Copyright 2012 jonas elmesten. All Rights Reserved.

local storyboard = require( “storyboard” )
local scene = storyboard.newScene()


– Code outside of listener functions (below) will only be executed once,
– unless storyboard.removeScene() is called.


– local forward references should go here –

– BEGINNING OF YOUR IMPLEMENTATION

--------------FUNKTIONER---------------------------------------
local function forrasidan( self, event )
if event.phase==“began” then

elseif event.phase == “ended” then
storyboard.gotoScene( “bild1”, “fade”, 500)
print( “letgo” )
return true
end
end

local function nastasida( self, event )
if event.phase==“began” then

elseif event.phase == “ended” then
storyboard.gotoScene( “bild3”, “fade”, 500)
print( “letgo” )
return true
end
end

local function plask ( self, event )
if event.phase==“began” then
audio.play(vattenplaskSnd)
print (“vatten”)
return true
end
end
– Called when the scene’s view does not exist:
function scene:createScene( event )
local Group2 = self.view
vattenplaskSnd = audio.loadSound(“vattenplask.mp3”)
bild2 = display.newImage(“bild2.jpg”)
tillbakaU = display.newImage(“tillbakaU.png”)
tillbakaU.y=_H/1.059
tillbakaN = display.newImage(“tillbakaN.png”)
CavesoundSnd = audio.loadSound(“Cavesound.mp3”)
vatten = display.newImage(“vatten.png”)
vatten.y=_H/1.8;

Group2:insert (bild2)
Group2:insert(vatten)
Group2:insert(tillbakaN)
Group2:insert(tillbakaU)

vatten.touch=plask
tillbakaN.touch=forrasidan
tillbakaU.touch=nastasida
print( “\n1: createScene event”)

end

– Called immediately after scene has moved onscreen:
function scene:enterScene( event )
local Group2 = self.view
storyboard.purgeScene(“bild1”)
print( “1: enterScene event” )
audio.setVolume( 1.5, { channel=5 } )
audio.play(CavesoundSnd,{fadein=200,channel=5, loops=-1})

tillbakaN:addEventListener(“touch”,tillbakaN)
tillbakaU:addEventListener(“touch”,tillbakaU)
vatten:addEventListener(“touch”,vatten)
end
– Called when scene is about to move offscreen:
function scene:exitScene( event )
local Group2 = self.view
print( “1: exitScene event” )
audio.fadeOut({ channel=5, time=2000 } )

storyboard.purgeScene( “bild1” )

end

– Called prior to the removal of scene’s “view” (display group)
function scene:destroyScene( event )
local Group2 = self.view
print( “((destroying menu’s view))” )

end


– END OF YOUR IMPLEMENTATION

– “createScene” event is dispatched if scene’s view does not exist
scene:addEventListener( “createScene”, scene )

– “enterScene” event is dispatched whenever scene transition has finished
scene:addEventListener( “enterScene”, scene )

– “exitScene” event is dispatched before next scene’s transition begins
scene:addEventListener( “exitScene”, scene )

– “destroyScene” event is dispatched before view is unloaded, which can be
– automatically unloaded in low memory situations, or explicitly via a call to
– storyboard.purgeScene() or storyboard.removeScene().
scene:addEventListener( “destroyScene”, scene )

return scene

[code] [import]uid: 197493 topic_id: 34655 reply_id: 138420[/import]

What I suspect the problem is has to do with your createScene() in bild2.lua. Look at these lines:

 Group2:insert (bild2)  
 Group2:insert(vatten)  
Group2:insert(tillbakaN)  
Group2:insert(tillbakaU)  

I suspect one of those display objects might be nil.

Make sure the filenames are valid and the images exist.

[import]uid: 199310 topic_id: 34655 reply_id: 138426[/import]

http://www.ladda-upp.se/bilder/ljcsqckhedpwj/ [import]uid: 197493 topic_id: 34655 reply_id: 138059[/import]

Can you post the code for intro.lua? Also I’d like to see the exitScene() function for the above module.
[import]uid: 199310 topic_id: 34655 reply_id: 138184[/import]

I feel bad for asking this, that is the code for bild2?

[import]uid: 199310 topic_id: 34655 reply_id: 138377[/import]

[code]
local storyboard = require( “storyboard” )
local scene = storyboard.newScene()
--------------FUNKTIONER---------------------------------------

local function bild (event)
intro.isVisible=true
audio.play(plingSnd)

return true
end

local function bytameny (event)
print(“helvete!”)
storyboard.gotoScene( “bild2”, “zoomInOutFade”, 1000)

return true
end

local t2=timer.performWithDelay(4400,bytameny,1)
– Called when the scene’s view does not exist:
function scene:createScene( event )
local Group0 = self.view
audio.setVolume( 0.1)
plingSnd = audio.loadSound(“pling.mp3”)
intro = display.newImage(“intro.jpg”)
Group0:insert (intro)
intro.isVisible=false

print( “\n1: createScene event”)

end
– Called immediately after scene has moved onscreen:
function scene:enterScene( event )
local Group0 = self.view

local t1=timer.performWithDelay(1500,bild,1)

print( “1: enterScene event” )

end
– Called when scene is about to move offscreen:
function scene:exitScene( event )
local Group0 = self.view
print( “1: exitScene event” )
storyboard.purgeScene( “intro” )

end
– Called prior to the removal of scene’s “view” (display group)
function scene:destroyScene( event )
local Group0 = self.view
print( “((destroying intro´s view))” )

end

– Called AFTER scene has finished moving offscreen:
function scene:didExitScene( event )
local Group0 = self.view
audio.stop()
audio.dispose( )
storyboard.removeScene(“intro”)

end


– END OF YOUR IMPLEMENTATION

– “createScene” event is dispatched if scene’s view does not exist
scene:addEventListener( “createScene”, scene )

– “enterScene” event is dispatched whenever scene transition has finished
scene:addEventListener( “enterScene”, scene )

– “exitScene” event is dispatched before next scene’s transition begins
scene:addEventListener( “exitScene”, scene )

– “destroyScene” event is dispatched before view is unloaded, which can be
– automatically unloaded in low memory situations, or explicitly via a call to
– storyboard.purgeScene() or storyboard.removeScene().
scene:addEventListener( “destroyScene”, scene )
– “didExitScene” event is dispatched after scene has finished transitioning out
scene:addEventListener( “didExitScene”, scene )


return scene

[code] [import]uid: 197493 topic_id: 34655 reply_id: 138275[/import]

Im so sorry! haha.

Dont know how i could cta + a the wrong lua?

It´s fixed now. :slight_smile: Look up again. [import]uid: 197493 topic_id: 34655 reply_id: 138409[/import]