这里我有一些代码:
function CountDown()
if(time_remaining > 1)then
time_remaining = time_remaining - 1;
print ("Loading menu")
local function main( event )
-- LAUNCH A ROCKET
if math.ceil(math.random() * 200) == 10 and launch == false then
Particles.GetEmitter ("Launcher1").rotation = -35
Particles.GetEmitter ("Launcher2").rotation = 20
Particles.StartEmitter("Launcher1", true)
Particles.StartEmitter("Launcher2", true)
end
-- UPDATE PARTICLES
Particles.Update()
end
-- timer.performWithDelay( 33, main, 1 )
Runtime:addEventListener( "enterFrame", main )
else
time_remaining = 0
print ("Load Go!")
menuLoad = transition.to( menuLoad, { time=575, y=-500 })
end
end
count_timer = timer.performWithDelay(1000, CountDown, time_total);
当我切换场景时,我通过 Particles.CleanUp() 取消了所有发射器,但我无法取消 math.random,无论如何它都会尝试启动我的发射器,但是因为它们已经是 nils (Particles.CleanUp),所以它给了我一个错误
Runtime error
...me development/Skipjack Rollout Design2/mainmenu.lua:560: attempt to index a nil value
stack traceback:
[C]: ?
...me development/Skipjack Rollout Design2/mainmenu.lua:560: in function <...me development/Skipjack Rollout Design2/mainmenu.lua:556>
?: in function <?:226>
请帮帮我!我如何取消 math.random?提前致谢!