Hi, I’m kind of a newbie and I was wondering why my app wasn’t transitioning to my Level 1 when I did the same exact thing in all my other parts, like the How To Play, and it worked just fine.
levelSelect.lua
module(…, package.seeall)
local director = require (“director”)
local physics = require(“physics”)
physics.start()
local director = require “director”
local widget = require( “widget” )
local storyboard = require “storyboard”
storyboard.purgeOnSceneChange = true
– Function to handle button events
local function handleButtonEventLevel1( event )
local phase = event.phase
if “ended” == phase then
director:changeScene(“lvl1”)
--else
--return nil
end
end
local function handleButtonEventToPage( event )
local phase = event.phase
if “ended” == phase then
director:changeScene(“page”)
end
end
– Main function - MUST return a display.newGroup()
function new()
local localGroup = display.newGroup()
local background = display.newImage(“bigtestsky.png”)
background.x=150
background.y=250
local fromStartToLevel1 = widget.newButton
{
left = 25,
top = 25,
width = 100,
height = 50,
defaultFile = “default.png”,
overFile = “over.png”,
label = “1”,
font = “LS”,
fontSize = 20,
labelColor = { default = {0,0,50}, over = {0,0,255} },
onEvent = handleButtonEventLevel1,
}
local fromLevelsToMainPage = widget.newButton
{
left = 25,
top = 415,
width = 100,
height = 50,
defaultFile = “default.png”,
overFile = “over.png”,
label = “BACK”,
font = “LS”,
fontSize = 20,
labelColor = { default = {0,0,50}, over = {0,0,255} },
onEvent = handleButtonEventToPage,
}
return localGroup
end
lvl1.lua
module(…,package.seeall) – If this line is not written, then the package will not be loaded.
function new() – Module ‘lvl1’ must have a new() function
local localGroup = display.newGroup() – The scene should create a display group
local physics = require(“physics”)
physics.start()
local widget = require( “widget” )
print(“Inside lvl1…”)
return localGroup; – And the scene should return the previously created display group.
end
(The level 1 code was provided by krs at stack overflow.com.)
And I have absolutely no idea why it doesn’t work, everything looks fine to me. So please help, thanks!