Skip to content

Commit

Permalink
Make DialogBox pause the player when appearing
Browse files Browse the repository at this point in the history
  • Loading branch information
Olivier Grech committed Feb 21, 2021
1 parent 550718d commit 451a025
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Scenes/Interface/DialogBox.gd
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ var _dial_arrow

var _text

var _manager

func _ready():
_manager = get_node("/root/Manager") as Manager
_manager.pause_player()

_dial_arrow = get_node("NinePatchRect/DialArrow")
_text = get_node("NinePatchRect/Text")

Expand Down
10 changes: 9 additions & 1 deletion Singletons/Manager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ var current_scene_name = ""

var current_scene_node : Node

var player_instance : Node

func _ready():
print("[MANAGER] Manager ready")
current_scene_node = get_node(PATH_CURRENT_SCENE_NODE)
Expand All @@ -37,8 +39,14 @@ func _load_map(map_name : String, player_x, player_y):
current_scene_name = map_name
print("[MANAGER] Loading map " + map_name)
var map_instance = load(PATH_MAP_SCENE + map_name + ".tscn").instance()
var player_instance = load(PATH_PLAYER_SCENE).instance()
player_instance = load(PATH_PLAYER_SCENE).instance()
player_instance.position.x = player_x * 8
player_instance.position.y = player_y * 8
map_instance.add_child(player_instance)
current_scene_node.add_child(map_instance)

func pause_player():
player_instance.set_paused(true)

func unpause_player():
player_instance.set_paused(false)

0 comments on commit 451a025

Please sign in to comment.