0
在這裏,我有一些代碼:(Corona SDK)如何取消math.random?
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,它會嘗試反正我開始發射,但由於他們已經是零(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? 在此先感謝!