diff --git a/scenes/game/game_camera.gd b/scenes/game/game_camera.gd new file mode 100644 index 0000000..aec9831 --- /dev/null +++ b/scenes/game/game_camera.gd @@ -0,0 +1,12 @@ +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/game_camera.tscn b/scenes/game/game_camera.tscn new file mode 100644 index 0000000..73d5203 --- /dev/null +++ b/scenes/game/game_camera.tscn @@ -0,0 +1,7 @@ +[gd_scene load_steps=2 format=3 uid="uid://dm068vaseh45n"] + +[ext_resource type="Script" path="res://scenes/game/game_camera.gd" id="1_ovc4s"] + +[node name="GameCamera" type="Camera2D"] +editor_draw_screen = false +script = ExtResource("1_ovc4s")