0
當玩家完成遊戲時,我希望重新開始場景,即我想重新加載當前場景。我曾嘗試故事板:reloadScene()沒有成功。 我也嘗試清除場景,然後重新加載它,也沒有任何結果。電暈:遊戲完成時重新啓動場景
local function onEveryFramePoop()
if(foodBalls) then
for i = foodBalls.numChildren, 1, -1 do
local ball = foodBalls[i]
if(ball.y > 200 and not(ball.isBeingPooped)) then
ball.isBeingPooped = true
local function tempRemove()
if(foodBalls.numChildren)then
ball:removeSelf()
ball = nil
print("removed")
end
end
physics.removeBody(ball)
transition.to(ball, {time = 2000, y = 400, onComplete = tempRemove})
audio.play(fartSound)
end
end
if(foodBalls.numChildren == 0 and food.numChildren == 2) then
reward.playRewardAnimation()
Runtime:removeEventListener("enterFrame", onEveryFramePoop)
timer.performWithDelay(2500, reloadSceneWithDelay)
end
end
end
function reloadSceneWithDelay()
storyboard.gotoScene("levels.levelDigestion") -- **HERE I WANT TO RESTART SCENE**
end
似乎什麼也沒有發生。我在這裏錯過了什麼?
你是不是指'if(foodBalls.numChildren> 0)then'而不是'if(foodBalls.numChildren)then'? – 2013-04-05 08:34:05
這不是問題!我只需要在reloadSceneWithDelay被調用時重新加載場景。 – Eyeball 2013-04-05 08:36:15
是的,這不是主要問題。但是,如果(a)then代替'then a〜= 0 then',那麼在Lua中編寫C程序員的錯誤非常頻繁。 – 2013-04-05 08:39:35