feat: bubble location
This commit is contained in:
@ -1,4 +1,5 @@
|
|||||||
extends Node2D
|
extends Node2D
|
||||||
|
class_name SuperCamera
|
||||||
|
|
||||||
@onready var area_2d: Area2D = $Area2D
|
@onready var area_2d: Area2D = $Area2D
|
||||||
@onready var camera: Camera2D = $Camera2D
|
@onready var camera: Camera2D = $Camera2D
|
||||||
@ -7,6 +8,7 @@ extends Node2D
|
|||||||
@export var minimum_location = 0
|
@export var minimum_location = 0
|
||||||
@export var maximum_location = 640
|
@export var maximum_location = 640
|
||||||
|
|
||||||
|
signal became_active(SuperCamera)
|
||||||
|
|
||||||
var is_player_in_range = false
|
var is_player_in_range = false
|
||||||
var player: Node2D
|
var player: Node2D
|
||||||
@ -29,6 +31,7 @@ func _process(delta: float) -> void:
|
|||||||
|
|
||||||
func _on_body_entered(body: Node2D) -> void:
|
func _on_body_entered(body: Node2D) -> void:
|
||||||
if body.name == "Player":
|
if body.name == "Player":
|
||||||
|
became_active.emit(self)
|
||||||
camera.make_current()
|
camera.make_current()
|
||||||
player = body
|
player = body
|
||||||
is_player_in_range = true
|
is_player_in_range = true
|
||||||
|
32
main.gd
Normal file
32
main.gd
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
extends Node2D
|
||||||
|
|
||||||
|
|
||||||
|
@onready var bubbles_back: TileMapLayer = $BubblesBack
|
||||||
|
@onready var bubbles_interior: TileMapLayer = $BubblesInterior
|
||||||
|
|
||||||
|
var active_camera: SuperCamera
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready() -> void:
|
||||||
|
for child in get_children():
|
||||||
|
if is_instance_of(child, SuperCamera):
|
||||||
|
child.became_active.connect(on_camera_became_active)
|
||||||
|
|
||||||
|
func on_camera_became_active(camera: SuperCamera):
|
||||||
|
active_camera = camera
|
||||||
|
|
||||||
|
|
||||||
|
func on_dialogue_started():
|
||||||
|
bubbles_back.visible = true
|
||||||
|
bubbles_interior.visible = true
|
||||||
|
|
||||||
|
func on_dialogue_ended():
|
||||||
|
bubbles_back.visible = false
|
||||||
|
bubbles_interior.visible = false
|
||||||
|
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
bubbles_back.global_position.x = active_camera.global_position.x
|
||||||
|
bubbles_interior.global_position.x = active_camera.global_position.x
|
||||||
|
|
1
main.gd.uid
Normal file
1
main.gd.uid
Normal file
@ -0,0 +1 @@
|
|||||||
|
uid://cvtt52wodbopm
|
@ -481,13 +481,13 @@ speed = 200.0
|
|||||||
acceleration = 0.177
|
acceleration = 0.177
|
||||||
|
|
||||||
[node name="Knight" type="AnimatedSprite2D" parent="."]
|
[node name="Knight" type="AnimatedSprite2D" parent="."]
|
||||||
|
visible = false
|
||||||
position = Vector2(1, -28)
|
position = Vector2(1, -28)
|
||||||
sprite_frames = SubResource("SpriteFrames_7l6ig")
|
sprite_frames = SubResource("SpriteFrames_7l6ig")
|
||||||
animation = &"idle"
|
animation = &"idle"
|
||||||
autoplay = "idle"
|
autoplay = "idle"
|
||||||
|
|
||||||
[node name="RedHood" type="AnimatedSprite2D" parent="."]
|
[node name="RedHood" type="AnimatedSprite2D" parent="."]
|
||||||
visible = false
|
|
||||||
position = Vector2(11, -19)
|
position = Vector2(11, -19)
|
||||||
sprite_frames = SubResource("SpriteFrames_mmwog")
|
sprite_frames = SubResource("SpriteFrames_mmwog")
|
||||||
animation = &"idle"
|
animation = &"idle"
|
||||||
|
1526
world_assets/bubbles.tres
Normal file
1526
world_assets/bubbles.tres
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user