From 31dc0e443efc0aae48e11a0d98e699dbed5c7dcf Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Wed, 10 Feb 2021 12:11:27 -0500 Subject: Added fade out around map change Also moved script system first in the loop so that the camera can catch up before rendering. Also added a map change from map 2 back to map 1. --- res/scripts/common.lua | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'res/scripts/common.lua') diff --git a/res/scripts/common.lua b/res/scripts/common.lua index e7af1cf..f43b2e0 100644 --- a/res/scripts/common.lua +++ b/res/scripts/common.lua @@ -38,3 +38,28 @@ end function StopSound(soundId) mixer():stopChannel(soundId) end + +function FadeToBlack(length) + local progress = 0.0 + while progress < length do + progress = progress + coroutine.yield() + setFadeoutProgress(progress / length) + end + setFadeoutProgress(1.0) +end + +function RemoveFadeout(length) + local progress = length + while progress > 0 do + progress = progress - coroutine.yield() + setFadeoutProgress(progress / length) + end + setFadeoutProgress(0.0) +end + +function ChangeMap(map, warp) + FadeToBlack(150) + loadMap("../res/maps/" .. map .. ".tmx", warp) + coroutine.yield() + RemoveFadeout(150) +end -- cgit 1.4.1