我正在尝试使用情节提要切换场景,但是当我按下按钮时,它会保留当前场景......我无法在互联网上的任何地方找到解决此问题的方法。终端提示正在进入打印“离开主菜单”的方法,我的下一个场景成功打开了,但是背景和按钮还是原来的场景。
local storyboard = require( "storyboard" )
local widget = require "widget"
local scene = storyboard.newScene()
local function onButton(event)
--local btn = event.target
--storyboard.gotoScene("sceneTemplate")
if event.phase == "release" then
print("play pressed")
storyboard.gotoScene("sceneTemplate")
end
end
function scene:createScene( event )
local group = self.view
print("menu scene created")
end
function scene:enterScene( event )
local group = self.view
print("menu scene viewing!")
local bgImage = display.newImage("images/mainBG.png",0,0);
local playButton = widget.newButton{
default = "images/playUp.png",
over = "images/playDown.png",
onEvent = onButton
}
playButton.x = 80
playButton.y = 20
end
function scene:exitScene( event )
local group = self.view
print("leaving main menu")
storyboard.removeScene("menu")
storyboard.removeAll()
display.remove(group)
group:removeSelf()
end