des bruits de pas

tralala
This commit is contained in:
Thomas
2025-03-31 17:24:16 +02:00
parent b091bb96db
commit 6517dd744e
16 changed files with 102 additions and 39 deletions

View File

@@ -1,6 +1,7 @@
extends Node2D
signal loadFromGameState
signal unloadFromScreen
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
@@ -9,3 +10,6 @@ func _ready() -> void:
func load_from_game_state():
$Bakery/player.set_feet_global_position(GameState.position_bakery)
emit_signal("loadFromGameState")
func unload():
emit_signal("unloadFromScreen")

View File

@@ -17,7 +17,10 @@ func _ready() -> void:
func start_game():
menu = get_child(0)
switch_scene(GameState.current_scene)
switch_to(GameState.current_scene)
func switch_to(to: String):
call_deferred("switch_scene", to)
func switch_scene(to: String):
var prev = get_child(0)
@@ -32,8 +35,12 @@ func switch_scene(to: String):
if bakery == null:
bakery = dest_bakery.instantiate()
scene = bakery
add_child(scene)
remove_child(prev)
scene.unload()
call_deferred("add_child", scene)
call_deferred("remove_child", prev)
call_deferred("init_scence", scene)
func init_scence(scene):
scene.load_from_game_state()
func open_menu():

View File

@@ -1,6 +1,7 @@
extends Node2D
signal loadFromGameState
signal unloadFromScreen
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
@@ -8,3 +9,6 @@ func _ready() -> void:
func load_from_game_state():
emit_signal("loadFromGameState")
func unload():
emit_signal("unloadFromScreen")

View File

@@ -73,3 +73,4 @@ position = Vector2(-142, -510)
[connection signal="loadFromGameState" from="." to="world/player" method="_on_load_from_game_state"]
[connection signal="loadFromGameState" from="." to="Thomas" method="_on_load_from_game_state"]
[connection signal="unloadFromScreen" from="." to="Thomas" method="_on_outside_unload_from_screen"]