local function doFadeWipe(state)
  fadeWipe = celeste.FadeWipe(engine.Scene, state, nil)
  engine.Scene:Add(fadeWipe)
  fadeWipe.duration = 2
  fadeWipe.EndTimer = 1
end


function onBegin()

  if getFlag("exittreehouse") then

    disablePause()
    disableMovement()
    wait(0.5)

    doFadeWipe(false)
    wait(1.3)

    setFlag("book3", false)
    setFlag("cat3", false)
    setFlag("game3", false)
    setFlag("toast3", false)
    setFlag("toy3", false)
    setFlag("exittreehouse", false)
    setFlag("outtreehouse")
    enableMovement()
    enablePause()

  end

end