diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2021-02-10 12:11:27 -0500 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2021-02-10 12:11:27 -0500 |
commit | 31dc0e443efc0aae48e11a0d98e699dbed5c7dcf (patch) | |
tree | 17e044698531fc1af82dddcbd144ae93d3ae0252 /res/scripts/common.lua | |
parent | fb58cb31804da7e5e40fc861927060a183962441 (diff) | |
download | tanetane-31dc0e443efc0aae48e11a0d98e699dbed5c7dcf.tar.gz tanetane-31dc0e443efc0aae48e11a0d98e699dbed5c7dcf.tar.bz2 tanetane-31dc0e443efc0aae48e11a0d98e699dbed5c7dcf.zip |
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.
Diffstat (limited to 'res/scripts/common.lua')
-rw-r--r-- | res/scripts/common.lua | 25 |
1 files changed, 25 insertions, 0 deletions
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 | |||
38 | function StopSound(soundId) | 38 | function StopSound(soundId) |
39 | mixer():stopChannel(soundId) | 39 | mixer():stopChannel(soundId) |
40 | end | 40 | end |
41 | |||
42 | function FadeToBlack(length) | ||
43 | local progress = 0.0 | ||
44 | while progress < length do | ||
45 | progress = progress + coroutine.yield() | ||
46 | setFadeoutProgress(progress / length) | ||
47 | end | ||
48 | setFadeoutProgress(1.0) | ||
49 | end | ||
50 | |||
51 | function RemoveFadeout(length) | ||
52 | local progress = length | ||
53 | while progress > 0 do | ||
54 | progress = progress - coroutine.yield() | ||
55 | setFadeoutProgress(progress / length) | ||
56 | end | ||
57 | setFadeoutProgress(0.0) | ||
58 | end | ||
59 | |||
60 | function ChangeMap(map, warp) | ||
61 | FadeToBlack(150) | ||
62 | loadMap("../res/maps/" .. map .. ".tmx", warp) | ||
63 | coroutine.yield() | ||
64 | RemoveFadeout(150) | ||
65 | end | ||