blob: 8fe078e6fcc5c49eb1635d124c1efc3d2ba4dd56 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# Undercooked - a game about cooking
# Copyright 2024 metamuffin
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, version 3 of the License only.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
class_name SceneTransition
extends Control
@onready var anim: AnimationPlayer = $AnimationPlayer
var black = true
var fading = false
signal close()
func _ready():
$ColorRect.visible = true
func fade_in():
if fading: push_error("transition busy (in)"); return
if not black: push_error("already faded in"); return
fading = true
anim.play_backwards("fade")
await anim.animation_finished
self.mouse_filter = Control.MOUSE_FILTER_IGNORE
fading = false; black = false
func fade_out():
if fading: push_error("transition busy (out)"); return
if black: push_error("already faded out"); return
fading = true
self.mouse_filter = Control.MOUSE_FILTER_STOP
anim.play("fade")
await anim.animation_finished
fading = false; black = true
func _exit_tree():
if fading: push_error("SceneTransition destroyed while fading")
|