It looks like to me that splashscreen.lua isn’t constructed as a storyboard module. All storyboard scenes must start with these two lines:
local storyboard = require( "storyboard" )
local scene = storyboard.newScene()
and must end with these lines:
scene:addEventListener( "createScene", scene )
scene:addEventListener( "enterScene", scene )
scene:addEventListener( "exitScene", scene )
scene:addEventListener( "destroyScene", scene )
return scene
In addition you have to provide functions for each of those 4 event listeners (technically you don’t need to implement them, but if you don’t storyboard won’t work… In other words you could do everything in createScene and ignore the others, but you have to either do createScene or enterScene. If no storyboard has nothing to manage.
Since you are struggling with storyboard, lets go with these are required. The code for each of these functions looks like this:
function scene:createScene( event )
local group = self.view
end
function scene:enterScene( event )
local group = self.view
end
function scene:exitScene( event )
local group = self.view
end
function scene:destroyScene( event )
local group = self.view
end
Most of your work is going into the createScene function. For simple scenes, there is probably nothing to do in the other three. Your:
display.setStatusBar(display.HiddenStatusBar)
print ("in load splashscreen file")
local localGroup = display.newGroup()
--BACKGROUND IMAGES
local background = display.newImage("gnomiessplashbg.png")
localGroup:insert(background)
background.x = display.stageWidth / 2
background.y = display.stageHeight / 2
--media.playSound( "gnomiesmusic.mp3", true )
local backgroundbg2 = display.newImage("gnomiessplashbg2.png")
localGroup:insert(backgroundbg2)
backgroundbg2.x = display.stageWidth / 2
backgroundbg2.y = display.stageHeight / 2
--BACKGROUND IMAGES END
--BUTTONS
local worlds = display.newImage("gnomiesPlaybutton.png" )
localGroup:insert(worlds)
worlds.x = display.stageWidth / 1.9
worlds.y = display.stageHeight / 2.1
--END BUTTONS
local function touched (event)
if ("ended" == event.phase) then
storyboard:changeScene( "worlds", "fade" )
end
end
worlds:addEventListener ("touch", touched)
should be:
function scene:createScene( event )
local group = self.view
display.setStatusBar(display.HiddenStatusBar) -- print ("in load splashscreen file")
-- local localGroup = display.newGroup() -- -- need this since it's display.newGroup() is the "group"
-- four lines up.
--BACKGROUND IMAGES
local background = display.newImage("gnomiessplashbg.png")
group:insert(background) -- must be in the scene's view ("group") to be managed.
background.x = display.stageWidth / 2
background.y = display.stageHeight / 2
--media.playSound( "gnomiesmusic.mp3", true )
local backgroundbg2 = display.newImage("gnomiessplashbg2.png")
group:insert(backgroundbg2)
backgroundbg2.x = display.stageWidth / 2
backgroundbg2.y = display.stageHeight / 2
--BACKGROUND IMAGES END
--BUTTONS
local worlds = display.newImage("gnomiesPlaybutton.png" )
group:insert(worlds)
worlds.x = display.stageWidth / 1.9
worlds.y = display.stageHeight / 2.1
--END BUTTONS
local function touched (event)
if ("ended" == event.phase) then
storyboard:changeScene( "worlds", "fade" )
end
end
worlds:addEventListener ("touch", touched)
end
[import]uid: 199310 topic_id: 34149 reply_id: 136925[/import]