我正在开发一个电晕应用程序,我需要一次又一次地重新加载相同的屏幕.我不知道如何做到这一点,任何人都可以用代码解释我这个
解决方法
1)
director class
2)main.lua
display.setStatusBar (display.HiddenStatusBar) --> Hides the status bar local director = require ("director") --> Imports director local mainGroup = display.newGroup() --> Creates a main group local function main() --> Adds main function mainGroup:insert(director.directorView) --> Adds the group from director director:changeScene("myscene") --> Change the scene,no effects return true end main()
3)myscene.lua
module(...,package.seeall) function new() local localGroup = display.newGroup() local redbutton = display.newImage ("redbutton.png") redbutton.x = 160 redbutton.y = 100 localGroup:insert(redbutton) local function pressRed (event) if event.phase == "ended" then director:changeScene ("reloader") end end redbutton:addEventListener ("touch",pressRed) return localGroup end
4)reloader.lua
module(...,package.seeall) function new() local localGroup = display.newGroup() local function listener( event ) director:changeScene ("myscene","fade") end timer.performWithDelay(50,listener ) return localGroup end