【问题标题】:Stop counting score on game over游戏结束时停止计算得分
【发布时间】:2013-02-22 17:05:06
【问题描述】:

我喜欢在事件发生时有一个触发器来停止计算分数,

function restartStopScore()
     score = score + 0
end

不会工作

score = 0
local scoreText = display.newText( "Score: " .. score, 20, 20,nil, 40)
scoreText:setTextColor(255,255,255)

local function getScore() -- increments Speed value every time it is called
 score = score + 1
 scoreText.text = "Score: " .. score 
 print("score" .. score)
 end
 timer.performWithDelay(1000, getScore, 0)


function restartScore()
     --reset the score
     score = 0   
end
 timer.performWithDelay(5000, restartScore, 1)--test trigger reset the score

【问题讨论】:

    标签: lua coronasdk


    【解决方案1】:

    你会想要设置一个boolean variable (true/false) 来记录你想要保持分数的时间。在顶部初始化 keeping_score

    keeping_score = true
    

    用这个来增加你的分数:

    if keeping_score then
        score = score + 1
    end
    

    您的启动/停止功能将如下所示:

    function restartStopScore()
        keeping_score = false
    end
    function restartContinueScore()
        keeping_score = true
    end
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多