1
Fork 0
mirror of https://github.com/Steffo99/hella-farm.git synced 2024-11-21 23:54:23 +00:00

Create basic GameCamera

This commit is contained in:
Steffo 2024-04-14 04:07:18 +02:00
parent cfe8091901
commit 735313b167
Signed by: steffo
GPG key ID: 5ADA3868646C3FC0
2 changed files with 19 additions and 0 deletions

View file

@ -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

View file

@ -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")