获取 Lua 中的速度(数字)的最大值。

我正在开发一个可以观察你跑得有多快的应用程序,为此我需要一个函数来显示你的最大速度,但是我不知道该怎么做。

local speedText = string.format( '%.3f', event.speed )
speed.y = 250
speed.x = 125
local numValue = tonumber(speedText)*3.6
if numValue ~= nil then
    speed.text = math.round( numValue )
end

我已经将我的“speedText”转换为上面看到的数字。

我使用Corona SDK/ Lua编写代码。

点赞
用户269870
用户269870

你需要在每帧中跟踪速度,并执行简单的操作,例如:

if event.speed > currentMaxSpeed then
    currentMaxSpeed = event.speed;
end
2013-02-14 12:35:07