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]
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]
local storyboard = require( “storyboard” )
local scene = storyboard.newScene()
– Code outside of listener functions (below) will only be executed once,
– unless storyboard.removeScene() is called.
--------------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
– “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 )
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]