gpt4 book ai didi

lua - 在电晕中重新加载屏幕

转载 作者:行者123 更新时间:2023-12-04 12:24:12 25 4
gpt4 key购买 nike

我正在电晕中开发一个应用程序,我需要一次又一次地重新加载同一个屏幕。我不知道该怎么做,任何人都可以用代码解释一下

最佳答案

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

关于lua - 在电晕中重新加载屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7962749/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com