add a fade thing
This commit is contained in:
parent
c6c3364081
commit
d3b4fc0e56
5
game.gd
5
game.gd
|
@ -11,6 +11,9 @@ var current_registry
|
||||||
onready var music_player = get_node("music_player")
|
onready var music_player = get_node("music_player")
|
||||||
onready var sfx_player = get_node("sfx_player")
|
onready var sfx_player = get_node("sfx_player")
|
||||||
|
|
||||||
|
# transition node
|
||||||
|
onready var transition = get_node("trans_layer/transition")
|
||||||
|
|
||||||
signal on_music_volume_changed(new_value)
|
signal on_music_volume_changed(new_value)
|
||||||
signal on_sfx_volume_changed(new_value)
|
signal on_sfx_volume_changed(new_value)
|
||||||
signal on_reading_speed_changed(new_value)
|
signal on_reading_speed_changed(new_value)
|
||||||
|
@ -58,6 +61,8 @@ func _register_functions():
|
||||||
func _switch_scene_fnc(args):
|
func _switch_scene_fnc(args):
|
||||||
if args.size() == 1:
|
if args.size() == 1:
|
||||||
var scene_name = args[0]
|
var scene_name = args[0]
|
||||||
|
transition.start_transition()
|
||||||
|
yield(transition, "on_transition_completed")
|
||||||
SceneSwitcher.goto_scene(Scenes[scene_name])
|
SceneSwitcher.goto_scene(Scenes[scene_name])
|
||||||
|
|
||||||
func _on_game_started_set(v):
|
func _on_game_started_set(v):
|
||||||
|
|
56
game.tscn
56
game.tscn
|
@ -1,12 +1,60 @@
|
||||||
[gd_scene load_steps=2 format=2]
|
[gd_scene load_steps=3 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://game.gd" type="Script" id=1]
|
[ext_resource path="res://game.gd" type="Script" id=1]
|
||||||
|
[ext_resource path="res://transition.gd" type="Script" id=2]
|
||||||
|
|
||||||
[node name="Game" type="Node"]
|
[node name="Game" type="Node" index="0"]
|
||||||
|
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
[node name="music_player" type="AudioStreamPlayer" parent="." index="0"]
|
[node name="trans_layer" type="CanvasLayer" parent="." index="0"]
|
||||||
|
|
||||||
|
layer = 2
|
||||||
|
offset = Vector2( 0, 0 )
|
||||||
|
rotation = 0.0
|
||||||
|
scale = Vector2( 1, 1 )
|
||||||
|
transform = Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||||
|
|
||||||
|
[node name="transition" type="Control" parent="trans_layer" index="0"]
|
||||||
|
|
||||||
|
anchor_left = 0.0
|
||||||
|
anchor_top = 0.0
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
|
rect_clip_content = false
|
||||||
|
mouse_filter = 2
|
||||||
|
mouse_default_cursor_shape = 0
|
||||||
|
size_flags_horizontal = 1
|
||||||
|
size_flags_vertical = 1
|
||||||
|
script = ExtResource( 2 )
|
||||||
|
_sections_unfolded = [ "Mouse" ]
|
||||||
|
|
||||||
|
[node name="background" type="ColorRect" parent="trans_layer/transition" index="0"]
|
||||||
|
|
||||||
|
anchor_left = 0.0
|
||||||
|
anchor_top = 0.0
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
|
rect_clip_content = false
|
||||||
|
mouse_filter = 2
|
||||||
|
mouse_default_cursor_shape = 0
|
||||||
|
size_flags_horizontal = 1
|
||||||
|
size_flags_vertical = 1
|
||||||
|
color = Color( 0, 0, 0, 0 )
|
||||||
|
_sections_unfolded = [ "Mouse" ]
|
||||||
|
|
||||||
|
[node name="tween" type="Tween" parent="trans_layer/transition" index="1"]
|
||||||
|
|
||||||
|
repeat = false
|
||||||
|
playback_process_mode = 1
|
||||||
|
playback_speed = 1.0
|
||||||
|
playback/active = false
|
||||||
|
playback/repeat = false
|
||||||
|
playback/speed = 1.0
|
||||||
|
|
||||||
|
[node name="music_player" type="AudioStreamPlayer" parent="." index="1"]
|
||||||
|
|
||||||
stream = null
|
stream = null
|
||||||
volume_db = 0.0
|
volume_db = 0.0
|
||||||
|
@ -15,7 +63,7 @@ autoplay = false
|
||||||
mix_target = 0
|
mix_target = 0
|
||||||
bus = "Music"
|
bus = "Music"
|
||||||
|
|
||||||
[node name="sfx_player" type="AudioStreamPlayer" parent="." index="1"]
|
[node name="sfx_player" type="AudioStreamPlayer" parent="." index="2"]
|
||||||
|
|
||||||
stream = null
|
stream = null
|
||||||
volume_db = 0.0
|
volume_db = 0.0
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
[ext_resource path="res://dialog_layer.gd" type="Script" id=2]
|
[ext_resource path="res://dialog_layer.gd" type="Script" id=2]
|
||||||
[ext_resource path="res://ui/dialog_box.tscn" type="PackedScene" id=3]
|
[ext_resource path="res://ui/dialog_box.tscn" type="PackedScene" id=3]
|
||||||
|
|
||||||
[node name="first_scene" type="Node2D" index="0"]
|
[node name="first_scene" type="Node2D"]
|
||||||
|
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ script = ExtResource( 1 )
|
||||||
|
|
||||||
[node name="dialog_layer" type="CanvasLayer" parent="." index="1"]
|
[node name="dialog_layer" type="CanvasLayer" parent="." index="1"]
|
||||||
|
|
||||||
layer = 1
|
layer = 0
|
||||||
offset = Vector2( 0, 0 )
|
offset = Vector2( 0, 0 )
|
||||||
rotation = 0.0
|
rotation = 0.0
|
||||||
scale = Vector2( 1, 1 )
|
scale = Vector2( 1, 1 )
|
||||||
|
|
|
@ -12,7 +12,7 @@ script = ExtResource( 1 )
|
||||||
|
|
||||||
[node name="dialog_layer" type="CanvasLayer" parent="." index="1"]
|
[node name="dialog_layer" type="CanvasLayer" parent="." index="1"]
|
||||||
|
|
||||||
layer = 1
|
layer = 0
|
||||||
offset = Vector2( 0, 0 )
|
offset = Vector2( 0, 0 )
|
||||||
rotation = 0.0
|
rotation = 0.0
|
||||||
scale = Vector2( 1, 1 )
|
scale = Vector2( 1, 1 )
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
extends Control
|
||||||
|
|
||||||
|
onready var background = get_node("background")
|
||||||
|
onready var tween = get_node("tween")
|
||||||
|
|
||||||
|
signal on_transition_completed()
|
||||||
|
|
||||||
|
const TRANSITION_TIME = 1.0
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
pass
|
||||||
|
|
||||||
|
func start_transition():
|
||||||
|
|
||||||
|
tween.interpolate_property(
|
||||||
|
background, "color:a", background.color.a, 1.0,
|
||||||
|
TRANSITION_TIME, Tween.TRANS_QUAD,
|
||||||
|
Tween.EASE_IN_OUT
|
||||||
|
)
|
||||||
|
|
||||||
|
tween.start()
|
||||||
|
yield(tween, "tween_completed")
|
||||||
|
emit_signal("on_transition_completed")
|
||||||
|
|
||||||
|
tween.interpolate_property(
|
||||||
|
background, "color:a", background.color.a, 0.0,
|
||||||
|
TRANSITION_TIME, Tween.TRANS_QUAD,
|
||||||
|
Tween.EASE_IN_OUT
|
||||||
|
)
|
||||||
|
tween.start()
|
||||||
|
|
|
@ -16,7 +16,7 @@ content_margin_right = -1.0
|
||||||
content_margin_top = -1.0
|
content_margin_top = -1.0
|
||||||
content_margin_bottom = -1.0
|
content_margin_bottom = -1.0
|
||||||
|
|
||||||
[node name="dialog_box" type="Control" index="0"]
|
[node name="dialog_box" type="Control"]
|
||||||
|
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
|
|
Loading…
Reference in New Issue