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

Replace GameCamera.get_ancestor with the reference Game.camera

This commit is contained in:
Steffo 2024-04-14 04:09:36 +02:00
parent 1aa785c08a
commit 4b24dd1fc3
Signed by: steffo
GPG key ID: 5ADA3868646C3FC0
3 changed files with 4 additions and 13 deletions

View file

@ -1,12 +1,2 @@
extends Camera2D extends Camera2D
class_name GameCamera 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

@ -13,3 +13,4 @@ static func get_ancestor(start: Node) -> MainGame:
@onready var gold_counter: Counter = $"GoldCounter" @onready var gold_counter: Counter = $"GoldCounter"
@onready var camera: GameCamera = $"GameCamera"

View file

@ -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="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://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"] [sub_resource type="TileSet" id="TileSet_g2dkm"]
@ -21,7 +22,6 @@ format = 2
shape = SubResource("RectangleShape2D_p1lg5") shape = SubResource("RectangleShape2D_p1lg5")
debug_color = Color(1, 1, 1, 0) debug_color = Color(1, 1, 1, 0)
[node name="Camera" type="Camera2D" parent="."] [node name="GameCamera" parent="." instance=ExtResource("2_ci6f2")]
editor_draw_screen = false
[node name="GoldCounter" parent="." instance=ExtResource("2_7flt7")] [node name="GoldCounter" parent="." instance=ExtResource("2_7flt7")]