Add splash_screen scene
This commit is contained in:
parent
6c040d05da
commit
28fd165018
|
|
@ -12,9 +12,9 @@ config_version=5
|
|||
|
||||
config/name="Tales-of-PKMN"
|
||||
config/version="0.0.1dev"
|
||||
run/main_scene="uid://bicg07c42wm1t"
|
||||
run/main_scene="uid://bi3r04lqth7iq"
|
||||
config/features=PackedStringArray("4.7", "Forward Plus")
|
||||
boot_splash/image="uid://c28nuhy3im7y4"
|
||||
boot_splash/show_image=false
|
||||
config/icon="res://icon.svg"
|
||||
|
||||
[autoload]
|
||||
|
|
|
|||
35
scenes/splash_screen.tscn
Normal file
35
scenes/splash_screen.tscn
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
[gd_scene format=3 uid="uid://bi3r04lqth7iq"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://ddxoruhyuxesc" path="res://scripts/splash_screen.gd" id="1_hsxvm"]
|
||||
[ext_resource type="Texture2D" uid="uid://c28nuhy3im7y4" path="res://assets/textures/splash.png" id="2_4gp4q"]
|
||||
|
||||
[node name="SplashScreen" type="Control" unique_id=300161700]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_hsxvm")
|
||||
|
||||
[node name="AnimatedDisplay" type="TextureRect" parent="." unique_id=1433597692]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
texture = ExtResource("2_4gp4q")
|
||||
expand_mode = 1
|
||||
stretch_mode = 6
|
||||
|
||||
[node name="TransitionRect" type="ColorRect" parent="." unique_id=33546617]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
color = Color(1, 1, 1, 0)
|
||||
33
scripts/splash_screen.gd
Normal file
33
scripts/splash_screen.gd
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
extends Control
|
||||
|
||||
@onready var animated_display: TextureRect = %AnimatedDisplay
|
||||
@onready var transition_rect: ColorRect = %TransitionRect
|
||||
|
||||
@export var main_menu_scene_path : String = "res://scenes/main_menu.tscn"
|
||||
@export var splash_duration : float = 3.0
|
||||
@export var allow_skip : bool = true
|
||||
|
||||
const SCREEN_FADE_DURATION := 0.6
|
||||
|
||||
var is_transitioning : bool = false
|
||||
|
||||
func _ready() -> void:
|
||||
await get_tree().create_timer(splash_duration).timeout
|
||||
go_to_main_menu()
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
# permet de passer le splash en appuyant sur une touche ou en cliquant
|
||||
if allow_skip and !is_transitioning and event.is_pressed() and (event is InputEventKey or event is InputEventMouseButton):
|
||||
go_to_main_menu()
|
||||
|
||||
func go_to_main_menu() -> void:
|
||||
if is_transitioning: return
|
||||
is_transitioning = true
|
||||
|
||||
transition_rect.visible = true
|
||||
transition_rect.modulate.a = 0.0
|
||||
var tween := create_tween()
|
||||
tween.tween_property(transition_rect, "modulate:a", 1.0, SCREEN_FADE_DURATION)
|
||||
await tween.finished
|
||||
|
||||
get_tree().change_scene_to_file(main_menu_scene_path)
|
||||
1
scripts/splash_screen.gd.uid
Normal file
1
scripts/splash_screen.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://ddxoruhyuxesc
|
||||
Loading…
Reference in a new issue