godot-shooter / commit
Fix issue where destination sprite wasn't showing up while dragging.
actors/Player.tscn | 2 +- scenes/HUD.gd | 3 +-- scenes/World.gd | 5 +++++ scenes/World.tscn | 1 + utils/Utils.gd | 10 +++++----- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/actors/Player.tscn b/actors/Player.tscn index 49be807..f296983 100644 --- a/actors/Player.tscn +++ b/actors/Player.tscn @@ -239,7 +239,6 @@ margin_right = 422.0 margin_bottom = 218.0 [node name="Scores" type="VBoxContainer" parent="UI/PauseMenu/CenterContainer/PanelContainer/VBoxContainer/TabContainer"] -visible = false anchor_right = 1.0 anchor_bottom = 1.0 margin_left = 8.0 @@ -263,6 +262,7 @@ margin_bottom = 25.0 text = "No high scores yet!" [node name="Pref" type="VBoxContainer" parent="UI/PauseMenu/CenterContainer/PanelContainer/VBoxContainer/TabContainer"] +visible = false anchor_right = 1.0 anchor_bottom = 1.0 margin_left = 8.0 diff --git a/scenes/HUD.gd b/scenes/HUD.gd index f4cfcdf..f4cb76f 100644 --- a/scenes/HUD.gd +++ b/scenes/HUD.gd @@ -29,11 +29,10 @@ func _input(event: InputEvent) -> void: if event is InputEventScreenDrag: set_position_event(event.position) if event is InputEventMouseButton: -# Utils.log("signal position_set - mouse button", "pressed", event.pressed, "position", event.position) if not is_dragging and event.pressed: is_dragging = true get_tree().paused = true - set_position_event(event.position) + set_position_event(event.position) if is_dragging and not event.pressed: is_dragging = false get_tree().paused = false diff --git a/scenes/World.gd b/scenes/World.gd index 4ec89b9..ff5eb51 100644 --- a/scenes/World.gd +++ b/scenes/World.gd @@ -199,3 +199,8 @@ func _on_Player_debug() -> void: # completed_objectives = max_objectives player.debug() pass # Replace with function body. + +func _on_Player_destination_set() -> void: + $Destination.visible = player.is_destination_set + $Destination.global_position = player.destination + pass diff --git a/scenes/World.tscn b/scenes/World.tscn index 83ff076..57d9204 100644 --- a/scenes/World.tscn +++ b/scenes/World.tscn @@ -74,4 +74,5 @@ antialiased = true [connection signal="body_entered" from="Destination" to="." method="_on_Destination_body_entered"] [connection signal="debug" from="Player" to="." method="_on_Player_debug"] +[connection signal="destination_set" from="Player" to="." method="_on_Player_destination_set"] [connection signal="timeout" from="ShootTimer" to="." method="_on_ShootTimer_timeout"] diff --git a/utils/Utils.gd b/utils/Utils.gd index 3ce4ebf..9623c56 100644 --- a/utils/Utils.gd +++ b/utils/Utils.gd @@ -14,19 +14,19 @@ static func load_user_settings(path = SettingsClass.settings_path) -> Settings: var _err = save_game.open(path, File.READ) var text = save_game.get_as_text() if text.length() > 0: - var json = parse_json(text) + var json: Dictionary = parse_json(text) var data: Settings = Settings.new() - data.show_intro = json["show_intro"] - data.show_items = json["show_items"] + if json.has("show_intro"): + data.show_intro = json["show_intro"] + if json.has("show_items"): + data.show_items = json["show_items"] if json.has("high_scores"): data.high_scores = [] -# print("high scores", high_scores) for hs in json["high_scores"]: var score = hs["score"] var date = hs["date"] var high_score: Settings.HighScore = Settings.HighScore.new(score, date) data.high_scores.push_back(high_score) - # Utils.log("high scores", high_scores) return data var data: Settings = Settings.new()