From 28fd165018111b667b050759fd00d33192f42d55 Mon Sep 17 00:00:00 2001 From: TheThomaas Date: Sun, 27 Sep 2026 15:04:16 +0200 Subject: [PATCH] Add splash_screen scene --- project.godot | 4 ++-- scenes/splash_screen.tscn | 35 +++++++++++++++++++++++++++++++++++ scripts/splash_screen.gd | 33 +++++++++++++++++++++++++++++++++ scripts/splash_screen.gd.uid | 1 + 4 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 scenes/splash_screen.tscn create mode 100644 scripts/splash_screen.gd create mode 100644 scripts/splash_screen.gd.uid diff --git a/project.godot b/project.godot index 9eb2112..d79aa12 100644 --- a/project.godot +++ b/project.godot @@ -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] diff --git a/scenes/splash_screen.tscn b/scenes/splash_screen.tscn new file mode 100644 index 0000000..ed56730 --- /dev/null +++ b/scenes/splash_screen.tscn @@ -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) diff --git a/scripts/splash_screen.gd b/scripts/splash_screen.gd new file mode 100644 index 0000000..d3c1dbc --- /dev/null +++ b/scripts/splash_screen.gd @@ -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) diff --git a/scripts/splash_screen.gd.uid b/scripts/splash_screen.gd.uid new file mode 100644 index 0000000..5ccc621 --- /dev/null +++ b/scripts/splash_screen.gd.uid @@ -0,0 +1 @@ +uid://ddxoruhyuxesc