Jelajahi Sumber

:lipstick: Implemente le defilement des niveaux

Necessaire de transformer tous les Node2D en Controle. Mais cela rend
beaucoup plus facile l'implementation du defilement.
DricomDragon 10 bulan lalu
induk
melakukan
fc1bbe6088

+ 7 - 4
godot/composants/objets/planete/planete.gd

@@ -1,5 +1,5 @@
 class_name Planete
-extends Sprite2D
+extends BaseButton
 
 
 signal niveau_choisi(PackedScene)
@@ -7,6 +7,9 @@ signal niveau_choisi(PackedScene)
 @export var niveau: PackedScene
 
 
-func _quand_cliquable_recoit_evenement(_vue: Node, evenement: InputEvent, _index_forme: int) -> void:
-	if evenement.is_action_released("ui_clic"):
-		niveau_choisi.emit(niveau)
+func _ready() -> void:
+	pressed.connect(_quand_planete_est_cliquee)
+
+
+func _quand_planete_est_cliquee() -> void:
+	niveau_choisi.emit(niveau)

+ 1 - 3
godot/composants/objets/planete/planete.tscn

@@ -1,14 +1,12 @@
-[gd_scene load_steps=4 format=3 uid="uid://dohnm5dlvf8fs"]
+[gd_scene load_steps=3 format=3 uid="uid://dohnm5dlvf8fs"]
 
 [ext_resource type="Texture2D" uid="uid://cu1l78e0v6ia3" path="res://composants/objets/planete/images/01.png" id="1_vg0dv"]
-[ext_resource type="Script" path="res://composants/objets/planete/planete.gd" id="2_8n4yh"]
 
 [sub_resource type="CircleShape2D" id="CircleShape2D_taghb"]
 radius = 54.037
 
 [node name="Planete" type="Sprite2D"]
 texture = ExtResource("1_vg0dv")
-script = ExtResource("2_8n4yh")
 
 [node name="Cliquable" type="Area2D" parent="."]
 

+ 50 - 23
godot/exec/choix/choix_niveau.tscn

@@ -1,45 +1,72 @@
-[gd_scene load_steps=12 format=3 uid="uid://cnbv6y2ikfysg"]
+[gd_scene load_steps=13 format=3 uid="uid://cnbv6y2ikfysg"]
 
 [ext_resource type="Script" path="res://exec/choix/systeme_solaire.gd" id="1_1jmyy"]
 [ext_resource type="Script" path="res://exec/choix/choix_niveau.gd" id="1_nhye5"]
-[ext_resource type="PackedScene" uid="uid://dohnm5dlvf8fs" path="res://composants/objets/planete/planete.tscn" id="1_pbu8m"]
 [ext_resource type="Texture2D" uid="uid://kgs8gu7ayyar" path="res://composants/objets/planete/images/02.png" id="2_1herl"]
 [ext_resource type="Texture2D" uid="uid://b2pf3mx4ppxoy" path="res://exec/choix/espace_par_bevouliin.png" id="2_nist7"]
-[ext_resource type="PackedScene" uid="uid://cyyb8weydthjc" path="res://exec/niveaux/carre_simple.tscn" id="3_yhitu"]
 [ext_resource type="Texture2D" uid="uid://dciyah6rngop4" path="res://composants/objets/planete/images/07.png" id="5_ato7s"]
+[ext_resource type="Script" path="res://composants/objets/planete/planete.gd" id="5_hm38a"]
 [ext_resource type="PackedScene" uid="uid://18mfasfcx418" path="res://exec/niveaux/mini_centre.tscn" id="6_0v56c"]
 [ext_resource type="Texture2D" uid="uid://7npljbrmgqur" path="res://composants/objets/planete/images/11.png" id="7_63ppw"]
-[ext_resource type="PackedScene" uid="uid://b11cxtgl8mwvm" path="res://exec/niveaux/blob_facile.tscn" id="7_knc84"]
-[ext_resource type="PackedScene" uid="uid://dh15j87pa6rul" path="res://exec/niveaux/jdll2024.tscn" id="8_h20se"]
+[ext_resource type="PackedScene" uid="uid://b11cxtgl8mwvm" path="res://exec/niveaux/blob_facile.tscn" id="8_coqpc"]
+[ext_resource type="Texture2D" uid="uid://cu1l78e0v6ia3" path="res://composants/objets/planete/images/01.png" id="9_mgdr1"]
+[ext_resource type="PackedScene" uid="uid://cyyb8weydthjc" path="res://exec/niveaux/carre_simple.tscn" id="10_m6fgg"]
+[ext_resource type="PackedScene" uid="uid://dh15j87pa6rul" path="res://exec/niveaux/jdll2024.tscn" id="12_5dpbk"]
 
 [node name="ChoixNiveau" type="Node"]
 script = ExtResource("1_nhye5")
 
-[node name="FondSpatial" type="Sprite2D" parent="."]
-texture = ExtResource("2_nist7")
-centered = false
+[node name="DefilementNiveaux" type="ScrollContainer" parent="."]
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
 
-[node name="SystemeSolaire" type="Node2D" parent="."]
+[node name="SystemeSolaire" type="TextureRect" parent="DefilementNiveaux"]
+layout_mode = 2
+texture = ExtResource("2_nist7")
 script = ExtResource("1_1jmyy")
 
-[node name="PlaneteNaine" parent="SystemeSolaire" instance=ExtResource("1_pbu8m")]
-position = Vector2(113, 137)
-texture = ExtResource("5_ato7s")
+[node name="PlaneteNaine" type="TextureButton" parent="DefilementNiveaux/SystemeSolaire"]
+layout_mode = 0
+offset_left = -18.0
+offset_top = 72.0
+offset_right = 205.0
+offset_bottom = 216.0
+texture_normal = ExtResource("5_ato7s")
+script = ExtResource("5_hm38a")
 niveau = ExtResource("6_0v56c")
 
-[node name="PlaneteLibre" parent="SystemeSolaire" instance=ExtResource("1_pbu8m")]
-position = Vector2(290, 354)
-texture = ExtResource("7_63ppw")
-niveau = ExtResource("8_h20se")
+[node name="PlaneteTerre" type="TextureButton" parent="DefilementNiveaux/SystemeSolaire"]
+layout_mode = 0
+offset_left = 208.0
+offset_top = 157.0
+offset_right = 431.0
+offset_bottom = 301.0
+texture_normal = ExtResource("2_1herl")
+script = ExtResource("5_hm38a")
+niveau = ExtResource("8_coqpc")
 
-[node name="PlaneteTerre" parent="SystemeSolaire" instance=ExtResource("1_pbu8m")]
-position = Vector2(298, 203)
-texture = ExtResource("2_1herl")
-niveau = ExtResource("7_knc84")
+[node name="PlaneteRouge" type="TextureButton" parent="DefilementNiveaux/SystemeSolaire"]
+layout_mode = 0
+offset_left = -36.0
+offset_top = 274.0
+offset_right = 187.0
+offset_bottom = 418.0
+texture_normal = ExtResource("9_mgdr1")
+script = ExtResource("5_hm38a")
+niveau = ExtResource("10_m6fgg")
 
-[node name="PlaneteRouge" parent="SystemeSolaire" instance=ExtResource("1_pbu8m")]
-position = Vector2(93, 352)
-niveau = ExtResource("3_yhitu")
+[node name="PlaneteLibre" type="TextureButton" parent="DefilementNiveaux/SystemeSolaire"]
+layout_mode = 0
+offset_left = 178.0
+offset_top = 370.0
+offset_right = 401.0
+offset_bottom = 514.0
+texture_normal = ExtResource("7_63ppw")
+script = ExtResource("5_hm38a")
+niveau = ExtResource("12_5dpbk")
 
 [node name="BarreMenu" type="Panel" parent="."]
 anchors_preset = 10

+ 2 - 2
godot/exec/choix/systeme_solaire.gd

@@ -1,7 +1,7 @@
-extends Node2D
+extends Node
 
 
-@onready var choix_niveau: Node = get_parent()
+@onready var choix_niveau: Node = find_parent("ChoixNiveau")
 
 
 func _ready() -> void: