My problem is that when I do ‘storyboard.gotoScene( “menu”, fade, 500 )’ the scene does not change. However when I change “menu” to some other file, the scene change works. In my main.lua file, the first screen that loads is the menu file. Can anyone tell me what the problem is? Here is the code in my menu file.
[code]
local storyboard = require( “storyboard” )
local scene = storyboard.newScene()
– include Corona’s “widget” library
local widget = require “widget”
– forward declarations and other locals
local playBtn
– ‘onRelease’ event listener for playBtn
local function onPlayBtnRelease()
storyboard.gotoScene( “select”, “fade”, 500 )
return true – indicates successful touch
end
– BEGINNING OF YOUR IMPLEMENTATION
– NOTE: Code outside of listener functions (below) will only be executed once,
– unless storyboard.removeScene() is called.
– Called when the scene’s view does not exist:
function scene:createScene( event )
local group = self.view
local sprite = require(“sprite”)
– display a background image
local background = display.newImageRect( “back.jpg”, display.contentWidth, display.contentHeight )
background:setReferencePoint( display.TopLeftReferencePoint )
background.x, background.y = 0, 0
– create/position logo/title image on upper-half of the screen
local titleLogo = display.newImageRect( “logo.gif”, 500, 200 )
titleLogo:setReferencePoint( display.CenterReferencePoint )
titleLogo.x = display.contentWidth * 0.5
titleLogo.y = 100
local titleImage = display.newImageRect( “motorbiker.gif”, 100, 70 )
titleImage:setReferencePoint( display.CenterReferencePoint )
titleImage.x = display.contentWidth * 0.3
titleImage.y = 180
local titlebike = display.newImageRect( “motorbiker.gif”, 100, 70 )
titlebike:setReferencePoint( display.CenterReferencePoint )
titlebike.x = display.contentWidth * 0.6
titlebike.y = 180
– create a widget button (which will loads level1.lua on release)
playBtn = widget.newButton{
label=“Play Now”,
labelColor = { default={30}, over={128} },
default=“macaqua.gif”,
font = “MarkerFelt-Thin”,
fontSize = 17,
over=“button-over.png”,
width=154, height=48,
onRelease = onPlayBtnRelease – event listener function
}
playBtn:setReferencePoint( display.CenterReferencePoint )
playBtn.x = display.contentWidth*0.15
playBtn.y = display.contentHeight - 40
BtnTwo = widget.newButton{
label=“How to Play”,
labelColor = { default={30}, over={128} },
default=“macaqua.gif”,
font = “MarkerFelt-Thin”,
fontSize = 17,
over=“button-over.png”,
width=154, height=48,
onRelease = onBtnTwoRelease – event listener function
}
BtnTwo:setReferencePoint( display.CenterReferencePoint )
BtnTwo.x = display.contentWidth*0.485
BtnTwo.y = display.contentHeight - 41
BtnThree = widget.newButton{
label=“Options”,
labelColor = { default={30}, over={128} },
default=“macaqua.gif”,
font = “MarkerFelt-Thin”,
fontSize = 17,
over=“button-over.png”,
width=154, height=48,
onRelease = onBtnThreeRelease – event listener function
}
BtnThree:setReferencePoint( display.CenterReferencePoint )
BtnThree.x = display.contentWidth*0.82
BtnThree.y = display.contentHeight - 43
– all display objects must be inserted into group
group:insert( background )
group:insert( titleLogo )
group:insert( playBtn )
group:insert( BtnTwo )
group:insert( BtnThree )
group:insert( titleImage )
group:insert( titlebike )
local player = display.newGroup()
local screen = display.newGroup()
–CREATE THE SPRITE SHEET ANIMATION ON MENU
local spriteSheet = sprite.newSpriteSheet(“motorbiker.gif”, 100, 100)
local monsterSet = sprite.newSpriteSet(spriteSheet, 1, 1)
sprite.add(monsterSet, “running”, 1, 1, 600, 0)
sprite.add(monsterSet, “jumping”, 1, 1, 1, 1)
–set the different variables we will use for our monster sprite
–also sets and starts the first animation for the monster
local monster = sprite.newSprite(monsterSet)
monster:prepare(“running”)
monster:play()
monster.x = 48
monster.y = 300
–these are 2 variables that will control the falling and jumping of the monster
monster.gravity = -6
monster.accel = 0
–rectangle used for our collision detection
–it will always be in front of the monster sprite
–that way we know if the monster hit into anything
local collisionRect = display.newRect(monster.x + 36, monster.y, 1, 70)
collisionRect.strokeWidth = 1
collisionRect:setFillColor(140, 140, 140)
collisionRect:setStrokeColor(180, 180, 180)
collisionRect.alpha = 0
–used to put everything on the screen into the screen group
–this will let us change the order in which sprites appear on
–the screen if we want. The earlier it is put into the group the
–further back it will go
screen:insert(backbackground)
screen:insert(backgroundfar)
screen:insert(backgroundnear1)
screen:insert(backgroundnear2)
screen:insert(blocks)
screen:insert(monster)
screen:insert(collisionRect)
– end of sprite sheet animation
end
– Called immediately after scene has moved onscreen:
function scene:enterScene( event )
local group = self.view
– INSERT code here (e.g. start timers, load audio, start listeners, etc.)
storyboard.enterScene(“menu”)
return true
end
– Called when scene is about to move offscreen:
function scene:exitScene( event )
local group = self.view
– INSERT code here (e.g. stop timers, remove listenets, unload sounds, etc.)
end
– If scene’s view is removed, scene:destroyScene() will be called just prior to:
function scene:destroyScene( event )
local group = self.view
if playBtn then
playBtn:removeSelf() – widgets must be manually removed
BtnThree:removeSelf()
BtnTwo: removeSelf()
BtnTwo = nil
BtnThree = nil
playBtn = nil
end
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 whenever 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
[text]
That is the scene I am trying to get to, and It doesn’t work. [import]uid: 175550 topic_id: 31265 reply_id: 331265[/import]