diff --git a/scenes/game/game_camera.gd b/scenes/game/game_camera.gd index aec9831..3c50b21 100644 --- a/scenes/game/game_camera.gd +++ b/scenes/game/game_camera.gd @@ -1,12 +1,2 @@ extends Camera2D class_name GameCamera - - -## Get the first possible [GameCamera] instance by climbing the scene tree one ancestor at a time. -static func get_ancestor(start: Node) -> GameCamera: - var current = start - while current is Node: - if current is GameCamera: - return current - current = current.get_parent() - return null diff --git a/scenes/game/menu_game.gd b/scenes/game/menu_game.gd index c868f82..9ae7177 100644 --- a/scenes/game/menu_game.gd +++ b/scenes/game/menu_game.gd @@ -13,3 +13,4 @@ static func get_ancestor(start: Node) -> MainGame: @onready var gold_counter: Counter = $"GoldCounter" +@onready var camera: GameCamera = $"GameCamera" diff --git a/scenes/game/menu_game.tscn b/scenes/game/menu_game.tscn index b393f62..e382071 100644 --- a/scenes/game/menu_game.tscn +++ b/scenes/game/menu_game.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=5 format=3 uid="uid://cxj5aud02f40j"] +[gd_scene load_steps=6 format=3 uid="uid://cxj5aud02f40j"] [ext_resource type="Script" path="res://scenes/game/menu_game.gd" id="1_x18yb"] [ext_resource type="PackedScene" uid="uid://brvbtvt4em32" path="res://behaviours/counter.tscn" id="2_7flt7"] +[ext_resource type="PackedScene" uid="uid://dm068vaseh45n" path="res://scenes/game/game_camera.tscn" id="2_ci6f2"] [sub_resource type="TileSet" id="TileSet_g2dkm"] @@ -21,7 +22,6 @@ format = 2 shape = SubResource("RectangleShape2D_p1lg5") debug_color = Color(1, 1, 1, 0) -[node name="Camera" type="Camera2D" parent="."] -editor_draw_screen = false +[node name="GameCamera" parent="." instance=ExtResource("2_ci6f2")] [node name="GoldCounter" parent="." instance=ExtResource("2_7flt7")]