当玩家完成游戏时,我想重新启动场景,即我想重新加载当前场景。我试过 storyboard: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
似乎什么都没有发生。我在这里想念什么?