如何在Corona中使用复位按钮重置变量值

我需要通过重置按钮来重置一个 Lua 变量 score 的值,请检查下面的代码:

local result = display.newText( score, 670, tabelaFundo5.y, native.systemFontBold, 35 )
resultadoFutebol:setFillColor(0,0,0)

在这里,变量 score 拥有一个动态的值,它可以正常输出,但是当我点击 RESET 按钮时,我需要重置它的值。我正在使用 corona SDK 和 Lua。

点赞
用户4841516
用户4841516

你的问题不够详细。但你只需要创建简单的按钮。

local button = display.newRect(300, 300, 100, 100)

local function onObjectTouch( event )
    if ( event.phase == "began" ) then
    elseif ( event.phase == "ended" ) then
        score = 0
        result.text = tostring(score)
    end
    return true
end

button:addEventListener("touch", onObjectTouch)
2015-12-02 12:20:00