mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-31 08:21:54 +08:00
feat(相机系统): 添加相机震动效果
- 在CameraManager中实现相机震动功能 - 为BigLaser添加触发相机震动的逻辑 - 在World场景中配置震动偏移量参数
This commit is contained in:
@@ -25,3 +25,4 @@ offset = Vector2(0, -80)
|
||||
process_callback = 0
|
||||
position_smoothing_enabled = true
|
||||
script = ExtResource("5_mk7bv")
|
||||
shakeOffset = 100.0
|
||||
|
||||
Binary file not shown.
@@ -1,6 +1,8 @@
|
||||
extends BulletBase
|
||||
class_name BigLaser
|
||||
|
||||
func spawn():
|
||||
CameraManager.shake(5000)
|
||||
func ai():
|
||||
rotation = lerp_angle(rotation, ((get_global_mouse_position() - position).angle()), 0.15)
|
||||
position = launcher.texture.global_position
|
||||
|
||||
@@ -2,10 +2,23 @@
|
||||
extends Camera2D
|
||||
class_name CameraManager
|
||||
|
||||
static var camera: Camera2D = null
|
||||
@export var shakeOffset: float = 100
|
||||
|
||||
var shaking: bool = false
|
||||
|
||||
static var instance: CameraManager = null
|
||||
|
||||
func _ready():
|
||||
camera = self
|
||||
instance = self
|
||||
func _physics_process(_delta):
|
||||
if is_instance_valid(UIState.player):
|
||||
position = UIState.player.position
|
||||
if shaking:
|
||||
position += MathTool.randv2_range(shakeOffset)
|
||||
|
||||
static func shake(millseconds: int = 1000):
|
||||
print("shake start")
|
||||
instance.shaking = true
|
||||
await TickTool.millseconds(millseconds)
|
||||
instance.shaking = false
|
||||
print("shake end")
|
||||
|
||||
Reference in New Issue
Block a user