mirror of
https://github.com/Steffo99/hella-farm.git
synced 2024-11-22 16:14:22 +00:00
Create basic GameCamera
This commit is contained in:
parent
cfe8091901
commit
735313b167
2 changed files with 19 additions and 0 deletions
12
scenes/game/game_camera.gd
Normal file
12
scenes/game/game_camera.gd
Normal 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
|
7
scenes/game/game_camera.tscn
Normal file
7
scenes/game/game_camera.tscn
Normal 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")
|
Loading…
Reference in a new issue