Hi
I have little problem with implementation… but it’s look like quite ok .?!?
This is my mainMenu file with is loading correctly from main.lua.
local storyboard = require( "storyboard" )
local scene = storyboard.newScene()
local \_W = display.contentWidth
local \_H = display.contentHeight
local playButton
local pushPlay = function(event)
if event.phase == "began" then
storyboard:gotoScene( "levels" , "fade" , 400 )
return true
end
end
function scene:createScene(event)
local screenGroup = self.view
playButton = display.newImage("playButton.png")
playButton.x = \_W /2
playButton.y = \_H /2
playButton:addEventListener("touch", pushPlay)
screenGroup:insert(playButton)
end
function scene:enterScene(event)
print("enterScene")
end
function scene:exitScene(event)
print("exitScene")
playButton:removeEventListener("touch", pushPlay)
end
function scene:destroyScene(event)
print ("destroyscene")
end
scene:addEventListener( "createScene", scene )
scene:addEventListener( "enterScene", scene )
scene:addEventListener( "exitScene", scene )
scene:addEventListener( "destroyScene", scene )
return scene
and then my levels file
local storyboard = require( "storyboard" )
local scene = storyboard.newScene()
local \_W = display.contentWidth
local \_H = display.contentHeight
local playOne = function(event)
if event.phase == "began" then
---- do something
end
end
local pushBack = function(event)
if event.phase == "release" then
storyboard.gotoScene("mainMenu", "fade", 400)
end
end
function scene:createScene(event)
local screenGroup = self.view
local levelone = display.newImage( "level10button.png" )
levelone.x = \_W/2 + 100
levelone.y = \_H/2
levelone:addEventListener("touch", playOne)
screenGroup:insert(levelone)
end
function scene:enterScene(event)
storyboard:removeScene( "mainMenu")
end
function scene:exitScene(event)
end
function scene:destroyScene(event)
print("destroyScene")
end
scene:addEventListener( "createScene", scene )
scene:addEventListener( "enterScene", scene )
scene:addEventListener( "exitScene", scene )
scene:addEventListener( "destroyScene", scene )
return scene
The problem is that I can not load levels.lua file
Error :
Runtime error
bad argument #1 to ‘require’ (string expected, got table)
stack traceback:
[C]: ?
[C]: in function ‘require’
?: in function ‘gotoScene’
…aIRensuXU+++TI/-Tmp-/TemporaryItems/303/mainMenu.lua:47: in function <…airensuxu>
?: in function <?:215>
and one more thing… I have to remove or purge scene in next scene right ? so first loading scene and then cleaning or removing it in next scene ?
[import]uid: 13156 topic_id: 17766 reply_id: 317766[/import] </…airensuxu>
[import]uid: 13156 topic_id: 17766 reply_id: 67771[/import]
? [import]uid: 12704 topic_id: 17766 reply_id: 67773[/import]