diff --git a/assets/textures/splash2.png b/assets/textures/splash2.png new file mode 100644 index 0000000..c880e24 Binary files /dev/null and b/assets/textures/splash2.png differ diff --git a/assets/textures/splash2.png.import b/assets/textures/splash2.png.import new file mode 100644 index 0000000..b8b0793 --- /dev/null +++ b/assets/textures/splash2.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dhovl8qbhk1xe" +path="res://.godot/imported/splash2.png-975b5ae55910322c5b4e9c302583fe54.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/textures/splash2.png" +dest_files=["res://.godot/imported/splash2.png-975b5ae55910322c5b4e9c302583fe54.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/game/ui/splash_screen/splash_screen.gd b/game/ui/splash_screen/splash_screen.gd index 44a6940..545a2d1 100644 --- a/game/ui/splash_screen/splash_screen.gd +++ b/game/ui/splash_screen/splash_screen.gd @@ -1,33 +1,38 @@ extends Control -@onready var animated_display: TextureRect = %AnimatedDisplay -@onready var transition_rect: ColorRect = %TransitionRect - -@export var main_menu_scene_path : String = "res://game/ui/main_menu/main_menu.tscn" -@export var splash_duration : float = 3.0 +@export var load_scene : PackedScene @export var allow_skip : bool = true +@export var splash_screen_container: Node -const SCREEN_FADE_DURATION := 0.6 +@export_group("Timings") +@export var in_time : float = 0.5 +@export var fade_in_time : float = 1.5 +@export var pause_time : float = 1.5 +@export var fade_out_time : float = 1.5 +@export var out_time : float = 0.5 -var is_transitioning : bool = false +var splash_screens = [] func _ready() -> void: - await get_tree().create_timer(splash_duration).timeout - go_to_main_menu() + get_screens() + fade() 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() + if allow_skip and event.is_pressed(): + get_tree().change_scene_to_packed(load_scene) -func go_to_main_menu() -> void: - if is_transitioning: return - is_transitioning = true +func get_screens() -> void: + splash_screens = splash_screen_container.get_children() + for screen in splash_screens: + screen.modulate.a = 0.0 - 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) +func fade() -> void: + for screen in splash_screens: + var tween = self.create_tween() + tween.tween_interval(in_time) + tween.tween_property(screen, "modulate:a", 1.0, fade_in_time) + tween.tween_interval(pause_time) + tween.tween_property(screen, "modulate:a", 0.0, fade_out_time) + tween.tween_interval(out_time) + await tween.finished + get_tree().change_scene_to_packed(load_scene) diff --git a/game/ui/splash_screen/splash_screen.tscn b/game/ui/splash_screen/splash_screen.tscn index 0dc4c35..8175534 100644 --- a/game/ui/splash_screen/splash_screen.tscn +++ b/game/ui/splash_screen/splash_screen.tscn @@ -2,8 +2,10 @@ [ext_resource type="Script" uid="uid://ddxoruhyuxesc" path="res://game/ui/splash_screen/splash_screen.gd" id="1_hsxvm"] [ext_resource type="Texture2D" uid="uid://c28nuhy3im7y4" path="res://assets/textures/splash.png" id="2_4gp4q"] +[ext_resource type="PackedScene" uid="uid://bluq6da7tku3d" path="res://game/ui/main_menu/main_menu.tscn" id="2_cob3s"] +[ext_resource type="Texture2D" uid="uid://dhovl8qbhk1xe" path="res://assets/textures/splash2.png" id="4_cob3s"] -[node name="SplashScreen" type="Control" unique_id=300161700] +[node name="SplashScreen" type="Control" unique_id=300161700 node_paths=PackedStringArray("splash_screen_container")] layout_mode = 3 anchors_preset = 15 anchor_right = 1.0 @@ -11,25 +13,37 @@ anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 script = ExtResource("1_hsxvm") +load_scene = ExtResource("2_cob3s") +splash_screen_container = NodePath("SplashScreenContainer") +fade_in_time = 0.5 +pause_time = 0.5 +fade_out_time = 0.5 -[node name="AnimatedDisplay" type="TextureRect" parent="." unique_id=1433597692] -unique_name_in_owner = true +[node name="ColorRect" type="ColorRect" parent="." unique_id=140381773] layout_mode = 1 anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 +color = Color(0.14117648, 0.14117648, 0.14117648, 1) + +[node name="SplashScreenContainer" type="MarginContainer" parent="." unique_id=71933636] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="Screen1" type="TextureRect" parent="SplashScreenContainer" unique_id=1430161342] +layout_mode = 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) +[node name="Screen2" type="TextureRect" parent="SplashScreenContainer" unique_id=708644296] +layout_mode = 2 +texture = ExtResource("4_cob3s") +expand_mode = 1 +stretch_mode = 6