优化相机移动问题,丝滑运镜
This commit is contained in:
parent
1c2fc4fb70
commit
2f5e2128e3
@ -9,7 +9,7 @@ keys,zh_CN,en
|
|||||||
方启钊,方启钊,"Fang Qizhao"
|
方启钊,方启钊,"Fang Qizhao"
|
||||||
方小蝉,方小蝉,"Fang Xiaochan"
|
方小蝉,方小蝉,"Fang Xiaochan"
|
||||||
小男孩,小男孩,"Little Boy"
|
小男孩,小男孩,"Little Boy"
|
||||||
小蝉,小蝉,"Little Cicada"
|
小蝉,小蝉,"Little Chan"
|
||||||
男孩黄,男孩黄,"Boy in Yellow"
|
男孩黄,男孩黄,"Boy in Yellow"
|
||||||
男孩蓝,男孩蓝,"Boy in Blue"
|
男孩蓝,男孩蓝,"Boy in Blue"
|
||||||
小肉圆,小肉圆,"Pudgy"
|
小肉圆,小肉圆,"Pudgy"
|
||||||
|
|
@ -69,13 +69,12 @@ func focus_node(node: Node2D, duration := 0.0) -> void:
|
|||||||
marker.focus_node(node, duration)
|
marker.focus_node(node, duration)
|
||||||
|
|
||||||
|
|
||||||
func focus_player_and_reset_zoom(duration := 1.2) -> void:
|
func focus_player_and_reset_zoom(duration := 1.0) -> void:
|
||||||
var marker = get_camera_marker()
|
var marker = get_camera_marker()
|
||||||
if marker:
|
if marker:
|
||||||
# marker.force_offset = Vector2.ZERO
|
# 延长可更丝滑
|
||||||
marker.tween_zoom(1.0, duration)
|
marker.tween_zoom(1.0, duration)
|
||||||
# 运镜更平滑一些
|
marker.focus_node(get_player(), duration)
|
||||||
marker.focus_node(get_player(), duration + .3)
|
|
||||||
|
|
||||||
|
|
||||||
func get_lock() -> PlayerReenterLock:
|
func get_lock() -> PlayerReenterLock:
|
||||||
|
@ -164,11 +164,11 @@ func _do_action() -> void:
|
|||||||
status = STATUS_TRANSITIONING
|
status = STATUS_TRANSITIONING
|
||||||
icount += 1
|
icount += 1
|
||||||
sfx.play()
|
sfx.play()
|
||||||
SceneManager.focus_node(self)
|
SceneManager.focus_node(self, 0.5)
|
||||||
SceneManager.get_camera_marker().tween_zoom(2.0)
|
SceneManager.get_camera_marker().tween_zoom(1.5, 1.2)
|
||||||
var tween = create_tween()
|
var tween = create_tween()
|
||||||
tween.tween_interval(0.8)
|
tween.tween_interval(0.5)
|
||||||
tween.tween_property(container, "modulate:a", 1.0, 0.7)
|
tween.tween_property(container, "modulate:a", 1.0, 0.8)
|
||||||
tween.tween_callback(func(): status = STATUS_INSPECTING_COVER)
|
tween.tween_callback(func(): status = STATUS_INSPECTING_COVER)
|
||||||
# 改变信号源
|
# 改变信号源
|
||||||
sign_mark.interacted.connect(_on_interacted)
|
sign_mark.interacted.connect(_on_interacted)
|
||||||
|
@ -155,6 +155,6 @@ layout_mode = 2
|
|||||||
size_flags_horizontal = 4
|
size_flags_horizontal = 4
|
||||||
size_flags_vertical = 8
|
size_flags_vertical = 8
|
||||||
theme_override_fonts/font = ExtResource("7_ianbs")
|
theme_override_fonts/font = ExtResource("7_ianbs")
|
||||||
text = "Q: Exit E: Read"
|
text = "Q: ui_退出 E: ui_阅读"
|
||||||
horizontal_alignment = 1
|
horizontal_alignment = 1
|
||||||
vertical_alignment = 1
|
vertical_alignment = 1
|
||||||
|
@ -122,7 +122,6 @@ func _show_os():
|
|||||||
|
|
||||||
|
|
||||||
func _show_balloon(res, title):
|
func _show_balloon(res, title):
|
||||||
# SceneManager.focus_node(self)
|
|
||||||
DialogueManager.show_dialogue_balloon(res, title)
|
DialogueManager.show_dialogue_balloon(res, title)
|
||||||
# note viewing animation
|
# note viewing animation
|
||||||
SceneManager.lock_player(0, action)
|
SceneManager.lock_player(0, action)
|
||||||
|
@ -4,9 +4,6 @@ class_name CameraFocusMarker extends Camera2D
|
|||||||
@export var force_offset := Vector2.ZERO
|
@export var force_offset := Vector2.ZERO
|
||||||
# @export_group("Status")
|
# @export_group("Status")
|
||||||
# @export var lock_horizontal = true
|
# @export var lock_horizontal = true
|
||||||
@export_group("Config")
|
|
||||||
@export var half_screen_size := Vector2(564, 240) / 2.0
|
|
||||||
@export var shaded_height := 38
|
|
||||||
@export_group("Shake", "shake_")
|
@export_group("Shake", "shake_")
|
||||||
@export var shake_strength := 0.0
|
@export var shake_strength := 0.0
|
||||||
@export var shake_recovery_speed := 4.0
|
@export var shake_recovery_speed := 4.0
|
||||||
@ -16,7 +13,6 @@ var speed := 2.0
|
|||||||
var _tweeked_position := Vector2.ZERO
|
var _tweeked_position := Vector2.ZERO
|
||||||
|
|
||||||
var zoom_tween: Tween
|
var zoom_tween: Tween
|
||||||
var _focus_offset := Vector2.ZERO
|
|
||||||
var shake_ignore_boundary := false
|
var shake_ignore_boundary := false
|
||||||
|
|
||||||
|
|
||||||
@ -33,7 +29,7 @@ func shake_camera(strength := 6.0, recovery_speed := 2.0, ignore_boundary := tru
|
|||||||
|
|
||||||
func reset_position_immediately():
|
func reset_position_immediately():
|
||||||
if focusing_node:
|
if focusing_node:
|
||||||
progressing_position = focusing_node.global_position + _tweeked_position + force_offset
|
progressing_position = (focusing_node.global_position + _tweeked_position + force_offset)
|
||||||
global_position = progressing_position
|
global_position = progressing_position
|
||||||
print("CameraFocusMarker reset_position_immediately to:", global_position)
|
print("CameraFocusMarker reset_position_immediately to:", global_position)
|
||||||
|
|
||||||
@ -72,6 +68,7 @@ func _physics_process(delta: float) -> void:
|
|||||||
# handle shake
|
# handle shake
|
||||||
if shake_strength > 0.0:
|
if shake_strength > 0.0:
|
||||||
# 让 shake_strength 逐帧衰减
|
# 让 shake_strength 逐帧衰减
|
||||||
|
shake_recovery_speed = min(0.1, shake_recovery_speed)
|
||||||
shake_strength = lerpf(shake_strength, 0.0, shake_recovery_speed * delta)
|
shake_strength = lerpf(shake_strength, 0.0, shake_recovery_speed * delta)
|
||||||
# [-shake_strength, +shake_strength] 范围内的同时,尽可能偏离中心
|
# [-shake_strength, +shake_strength] 范围内的同时,尽可能偏离中心
|
||||||
# 在 0 – 2π 之间随机一个方向,在 _last_shake_angle 的对角范围
|
# 在 0 – 2π 之间随机一个方向,在 _last_shake_angle 的对角范围
|
||||||
@ -93,9 +90,13 @@ func _physics_process(delta: float) -> void:
|
|||||||
zoom = Vector2(zoom_ratio, zoom_ratio)
|
zoom = Vector2(zoom_ratio, zoom_ratio)
|
||||||
|
|
||||||
|
|
||||||
|
var half_screen_size := Vector2(564, 240) / 2.0
|
||||||
|
var shading_y := 38.0
|
||||||
|
|
||||||
|
|
||||||
func _clamp_boundary(target: Vector2) -> Vector2:
|
func _clamp_boundary(target: Vector2) -> Vector2:
|
||||||
var margin = half_screen_size / zoom_ratio
|
var margin = half_screen_size / zoom_ratio
|
||||||
margin.y += shaded_height
|
margin.y += shading_y
|
||||||
target.x = clamp(target.x, limit_left + margin.x, limit_right - margin.x)
|
target.x = clamp(target.x, limit_left + margin.x, limit_right - margin.x)
|
||||||
target.y = clamp(target.y, limit_top + margin.y, limit_bottom - margin.y)
|
target.y = clamp(target.y, limit_top + margin.y, limit_bottom - margin.y)
|
||||||
return target
|
return target
|
||||||
@ -134,33 +135,13 @@ func focus_node(node: Node2D, duration := 0.0) -> void:
|
|||||||
focusing_node = null
|
focusing_node = null
|
||||||
return
|
return
|
||||||
if duration > 0.0:
|
if duration > 0.0:
|
||||||
_focus_offset = global_position - node.global_position
|
|
||||||
if tween_focus and tween_focus.is_running():
|
if tween_focus and tween_focus.is_running():
|
||||||
tween_focus.kill()
|
tween_focus.kill()
|
||||||
tween_focus = create_tween()
|
tween_focus = create_tween()
|
||||||
(
|
tween_focus.tween_method(_update_focus_progress, 0.0, 1.0, duration)
|
||||||
tween_focus
|
_update_focus_progress(0.0)
|
||||||
. tween_property(self, "_focus_offset", Vector2.ZERO, duration)
|
|
||||||
. set_trans(Tween.TRANS_SINE)
|
|
||||||
. set_ease(Tween.EASE_IN_OUT)
|
|
||||||
)
|
|
||||||
focusing_node = node
|
focusing_node = node
|
||||||
|
|
||||||
# var exited := false
|
|
||||||
# var exit_position: Vector2
|
|
||||||
# var enter_tree_tween: Tween
|
|
||||||
|
|
||||||
# func _exit_tree() -> void:
|
func _update_focus_progress(progress: float):
|
||||||
# exit_position = global_position
|
speed = 0.2 + 1.8 * smoothstep(0.0, 1.0, progress)
|
||||||
# exited = true
|
|
||||||
|
|
||||||
# func _enter_tree() -> void:
|
|
||||||
# if exited and is_node_ready():
|
|
||||||
# exited = false
|
|
||||||
# if enter_tree_tween and enter_tree_tween.is_running():
|
|
||||||
# enter_tree_tween.kill()
|
|
||||||
# enter_tree_tween = create_tween()
|
|
||||||
# global_position = exit_position
|
|
||||||
# enter_tree_tween.tween_property(self, "position", Vector2.ZERO, 0.2).set_trans(
|
|
||||||
# Tween.TRANS_CUBIC
|
|
||||||
# )
|
|
||||||
|
@ -90,15 +90,15 @@ func _dean_flip_book() -> void:
|
|||||||
func pre_game_intro():
|
func pre_game_intro():
|
||||||
SceneManager.lock_player()
|
SceneManager.lock_player()
|
||||||
var camera = SceneManager.get_camera_marker() as CameraFocusMarker
|
var camera = SceneManager.get_camera_marker() as CameraFocusMarker
|
||||||
camera.tween_zoom(1.5, 3.0)
|
camera.tween_zoom(1.5, 3.5)
|
||||||
var p = $"../DeployLayer/四小孩画鬼差的对话ambush/FocusPoint"
|
var p = $"../DeployLayer/四小孩画鬼差的对话ambush/FocusPoint"
|
||||||
camera.focus_node(p, 3.0)
|
camera.focus_node(p, 3.0)
|
||||||
await Util.wait(1.5)
|
await Util.wait(2.0)
|
||||||
DialogueManager.show_dialogue_balloon(dialogue_c01, "c01_s06_四个小孩画鬼差的对话")
|
DialogueManager.show_dialogue_balloon(dialogue_c01, "c01_s06_四个小孩画鬼差的对话")
|
||||||
await DialogueManager.dialogue_ended
|
await DialogueManager.dialogue_ended
|
||||||
# 重置镜头
|
# 重置镜头
|
||||||
SceneManager.focus_player_and_reset_zoom(2.5)
|
SceneManager.focus_player_and_reset_zoom(2.5)
|
||||||
await Util.wait(1.5)
|
await Util.wait(2.5)
|
||||||
await SceneManager.pop_os_with_str("c01_s06_熟悉的墙画")
|
await SceneManager.pop_os_with_str("c01_s06_熟悉的墙画")
|
||||||
SceneManager.unlock_player()
|
SceneManager.unlock_player()
|
||||||
|
|
||||||
|
@ -139,6 +139,7 @@ animations = [{
|
|||||||
}]
|
}]
|
||||||
|
|
||||||
[node name="S06" type="Node2D"]
|
[node name="S06" type="Node2D"]
|
||||||
|
position = Vector2(-1, 0)
|
||||||
metadata/_edit_horizontal_guides_ = [158.0, 91.0, 81.0]
|
metadata/_edit_horizontal_guides_ = [158.0, 91.0, 81.0]
|
||||||
|
|
||||||
[node name="Ground" parent="." instance=ExtResource("1_bitx7")]
|
[node name="Ground" parent="." instance=ExtResource("1_bitx7")]
|
||||||
|
@ -55,16 +55,12 @@ func _on_ground_ready() -> void:
|
|||||||
func intro() -> void:
|
func intro() -> void:
|
||||||
begger.play("杂戏团夜晚_小孩举碗呼吸")
|
begger.play("杂戏团夜晚_小孩举碗呼吸")
|
||||||
# SceneManager.freeze_player(0)
|
# SceneManager.freeze_player(0)
|
||||||
# SceneManager.focus_node(begger, 5.)
|
# SceneManager.focus_node(begger, 5.0)
|
||||||
Util.timer(1., _intro_dialog)
|
Util.timer(1., _intro_dialog)
|
||||||
|
|
||||||
|
|
||||||
func _intro_dialog() -> void:
|
func _intro_dialog() -> void:
|
||||||
DialogueManager.show_dialogue_balloon(dialogue_c01, "c01_s12_诡异的书店外发钱")
|
DialogueManager.show_dialogue_balloon(dialogue_c01, "c01_s12_诡异的书店外发钱")
|
||||||
# DialogueManager.dialogue_ended.connect(_on_intro_dialogue_ended, CONNECT_ONE_SHOT)
|
|
||||||
# func _on_intro_dialogue_ended(_res) -> void:
|
|
||||||
# SceneManager.focus_player_and_reset_zoom(5.)
|
|
||||||
# SceneManager.release_player()
|
|
||||||
|
|
||||||
|
|
||||||
func ambush_begger_interacted():
|
func ambush_begger_interacted():
|
||||||
|
@ -19,6 +19,48 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"c01_s06_孤儿院长廊围墙": {
|
||||||
|
"global": {
|
||||||
|
"enabled_items": {},
|
||||||
|
"player_x": 1300.0
|
||||||
|
},
|
||||||
|
"ground": {
|
||||||
|
&"AnimationPlayer": {},
|
||||||
|
&"Interactable桌椅": {
|
||||||
|
"interacted_times": 0
|
||||||
|
},
|
||||||
|
&"四小孩画鬼差的对话ambush": {
|
||||||
|
"played": false
|
||||||
|
},
|
||||||
|
&"桌椅ambush1": {
|
||||||
|
"played": false
|
||||||
|
},
|
||||||
|
&"桌椅ambush2": {
|
||||||
|
"played": false
|
||||||
|
},
|
||||||
|
&"桌椅ambush3": {
|
||||||
|
"played": false
|
||||||
|
},
|
||||||
|
&"猫鼠游戏失败ambush": {
|
||||||
|
"played": false
|
||||||
|
},
|
||||||
|
&"猫鼠游戏开始ambush": {
|
||||||
|
"played": false
|
||||||
|
},
|
||||||
|
&"猫鼠游戏胜利ambush": {
|
||||||
|
"played": false
|
||||||
|
},
|
||||||
|
&"猫鼠游戏重置ambush": {
|
||||||
|
"played": false
|
||||||
|
},
|
||||||
|
&"门口ambush": {
|
||||||
|
"played": false
|
||||||
|
},
|
||||||
|
&"门口对话ambush": {
|
||||||
|
"played": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"c01_s08_书店": {
|
"c01_s08_书店": {
|
||||||
"global": {
|
"global": {
|
||||||
"c01_shelf_game_success": false,
|
"c01_shelf_game_success": false,
|
||||||
|
Loading…
Reference in New Issue
Block a user