这是Lua中带有计时器而没有用户输入的场景转换所需代码的一个版本,就像幻灯片放映一样:
答案 0 :(得分:1)
main.lua:
display.setStatusBar(display.HiddenStatusBar)
local composer = require "composer"
composer.gotoScene("scene1")
这会直接带你到scene1。
scene1:
local composer = require ( "composer")
local scene = composer.newScene()
local function showScene2()
local options = {
effect = "fade",
time = 50,
}
composer.gotoScene( "scene2", options)
end
-- create scene
function scene:createScene ( event )
local sceneGroup = self.view
end
function scene:show( event )
local sceneGroup = self.view
local phase = event.phase
if ( phase == "will") then
local background = display.newImage("images/picture1.png", 240, 160)
sceneGroup:insert( background )
elseif ( phase == "did") then
timer.performWithDelay(3000, showScene2)
end
end
function scene:hide( event )
local sceneGroup = self.view
local phase = event.phase
end
--end
function scene:destroy( event )
local sceneGroup = self.view
end
scene:addEventListener( "create", scene)
scene:addEventListener( "show", scene)
scene:addEventListener( "hide", scene)
scene:addEventListener( "destroy", scene)
return scene
除了下一个场景的名字之外,scene2(etc ..)完全相同 -
-- local function showScene3()
-- composer.gotoScene( "scene3", options)
-- timer.performWithDelay(3000, showScene3)