des bruits de pas
tralala
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -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():
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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"]
|
||||
|
||||
Reference in New Issue
Block a user