Made transitions between cameras based on the screens real coordinates

This commit is contained in:
Rakarake 2024-11-28 23:14:08 +01:00
parent 4d87d3ae84
commit bb031edd82
3 changed files with 13 additions and 4 deletions

View file

@ -22,7 +22,7 @@ func _ready():
if follow_camera != null:
camera_stack.append(follow_camera)
func _physics_process(delta: float) -> void:
func _physics_process(delta: float):
# Camera updates
camera_transition_time_tmp -= delta
if camera_transition_time_tmp <= 0.0:
@ -56,7 +56,7 @@ func remove_camera(c):
func transition(_c):
camera_transition_time_tmp = camera_transition_time
camera_original_position = global_position
camera_original_position = get_screen_center_position()
# Recursively go through stack to inherit property
func try_inherit(enable_property, property):

View file

@ -252,6 +252,7 @@ inherit_limit = true
[node name="Camera" type="Camera2D" parent="Detatch" node_paths=PackedStringArray("follow_camera") groups=["flip_me"]]
process_callback = 0
limit_smoothed = true
position_smoothing_enabled = true
editor_draw_screen = false
script = ExtResource("18_kiohe")

View file

@ -1,10 +1,11 @@
[gd_scene load_steps=9 format=4 uid="uid://bepys2yg3mlfh"]
[gd_scene load_steps=10 format=4 uid="uid://bepys2yg3mlfh"]
[ext_resource type="Texture2D" uid="uid://bgw5itdndav4s" path="res://icon.svg" id="1_r51fb"]
[ext_resource type="Script" path="res://global/SceneCamera.gd" id="2_7hrj7"]
[ext_resource type="PackedScene" uid="uid://dlyt5o2dona1a" path="res://player/Player.tscn" id="2_8ykds"]
[ext_resource type="Script" path="res://global/FocusZone.gd" id="3_c8r6w"]
[ext_resource type="Script" path="res://player/ExtendedCamera.gd" id="3_mi107"]
[ext_resource type="Texture2D" uid="uid://3hyrbswjn4e" path="res://expressive_stone.png" id="6_3t7se"]
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_v18bm"]
texture = ExtResource("1_r51fb")
@ -30,7 +31,8 @@ tile_set = SubResource("TileSet_v0hen")
[node name="SceneCamera" type="Camera2D" parent="."]
position = Vector2(1460, 976)
enabled = false
limit_bottom = 1080
limit_left = -300
limit_bottom = 1174
editor_draw_screen = false
editor_draw_limits = true
script = ExtResource("2_7hrj7")
@ -49,6 +51,7 @@ enabled = false
limit_smoothed = true
script = ExtResource("3_mi107")
inherit_position = true
inherit_limit = true
[node name="Enter" type="Area2D" parent="CameraFocusZone"]
collision_layer = 0
@ -66,5 +69,10 @@ collision_mask = 4
position = Vector2(746, 388)
shape = SubResource("RectangleShape2D_h3vqu")
[node name="ExpressiveStone" type="Sprite2D" parent="."]
position = Vector2(1685, 480)
scale = Vector2(4.65625, 1.4375)
texture = ExtResource("6_3t7se")
[connection signal="body_entered" from="CameraFocusZone/Enter" to="CameraFocusZone" method="focus"]
[connection signal="body_entered" from="CameraFocusZone/Exit" to="CameraFocusZone" method="stop_focus"]