lua – 在日冕重新加载屏幕

前端之家收集整理的这篇文章主要介绍了lua – 在日冕重新加载屏幕前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在开发一个电晕应用程序,我需要一次又一次地重新加载相同的屏幕.我不知道如何做到这一点,任何人都可以用代码解释我这个

解决方法

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
原文链接:https://www.f2er.com/lua/274513.html

猜你在找的Lua相关文章