【问题标题】:change timer to 3 decimal places将计时器更改为小数点后 3 位
【发布时间】:2015-06-20 03:55:42
【问题描述】:

我有一个倒计时计时器,它从 3 开始倒计时到 0。我试图让它将计时器显示到小数点后 3 位。这样用户就可以看到毫秒数倒计时。例如:2.765

local function choice ( event )
    randCircle = circle[ math.random( #circle ) ]
    randCircle:setFillColor(1,0,0);

    local timeLimit = 3.000
        timeLeft = display.newText(timeLimit, randCircle.x, randCircle.y, native.systemFontBold, 36)
        timeLeft:setTextColor( 0,0,0 )
        sceneGroup:insert( timeLeft )

        local function timerDown()
           timeLimit = timeLimit - 1
           timeLeft.text = timeLimit
             if( timeLimit == 0 )then
                print( "Time Out" ) -- or do your code for time out
            end
        end
    aTimer = timer.performWithDelay( 1000,timerDown,timeLimit ) 

end
timer.performWithDelay( 2000, choice, 0 )

【问题讨论】:

    标签: function timer lua coronasdk


    【解决方案1】:

    试试:

    display.newText(string.format("%.3f",timeLimit),...
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-11-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-25
      • 2015-11-21
      • 1970-01-01
      相关资源
      最近更新 更多