如何每秒更新 math.random 的值?
tmrSpawn = timer.performWithDelay(math.random(9, 50), spawnBC3, 0)
它在 9/50 之间选择 1(并保持该值),但我希望它每次都刷新这个值,知道如何解决这个问题吗?
您应该修改spawnBC3函数:
local function spawnBC3()
-- your code here
if(tmrSpawn == nil) then
tmrSpawn = timer.performWithDelay(math.random(9, 50), spawnBC3)
else
timer.cancel( tmrSpawn )
end
end
--here we start the timer first time
local tmrSpawn = timer.performWithDelay(math.random(9, 50), spawnBC3)