Files
GMTK25/camera/camera.gd
Minimata 18d1b0b22d
All checks were successful
Create tag and build when new code gets to main / BumpTag (push) Successful in 6s
Create tag and build when new code gets to main / Export (push) Successful in 2m11s
feat: bubble location
2025-08-01 11:13:14 +02:00

43 lines
1.0 KiB
GDScript

extends Node2D
class_name SuperCamera
@onready var area_2d: Area2D = $Area2D
@onready var camera: Camera2D = $Camera2D
@export var should_follow_player = false
@export var minimum_location = 0
@export var maximum_location = 640
signal became_active(SuperCamera)
var is_player_in_range = false
var player: Node2D
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
if not should_follow_player or not is_player_in_range:
return
if player.global_position.x < minimum_location or player.global_position.x > maximum_location:
return
global_position.x = player.global_position.x
func _on_body_entered(body: Node2D) -> void:
if body.name == "Player":
became_active.emit(self)
camera.make_current()
player = body
is_player_in_range = true
func _on_body_exited(body: Node2D) -> void:
if body.name == "Player":
is_player_in_range = false