0

当玩家完成游戏时,我想重新启动场景,即我想重新加载当前场景。我试过 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

似乎什么都没有发生。我在这里想念什么?

4

1 回答 1

0

我没有使用故事板,但你可以试试这个:

在情节提要中创建一个黑色场景然后,当您要重新启动时,只需转到黑色场景,然后再转到您想去的场景。

问题可能与您试图从自身调用模块有关。

于 2013-04-05T11:29:37.460 回答