mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-28 23:11:54 +08:00
4c5842fb9e
统一使用load方法动态加载资源,减少启动时的内存占用 移动Manager类到Tools/Managers目录下 修复DirTool处理remap文件的问题
29 lines
935 B
GDScript
29 lines
935 B
GDScript
@tool
|
|
extends Camera2D
|
|
class_name CameraManager
|
|
|
|
@onready var animator: AnimationPlayer = $"%animator"
|
|
|
|
var shakeIntensity: float = 0
|
|
|
|
static var instance: CameraManager = null
|
|
|
|
func _ready():
|
|
instance = self
|
|
func _physics_process(_delta):
|
|
if is_instance_valid(UIState.player):
|
|
position = UIState.player.position
|
|
position += MathTool.randv2_range(shakeIntensity)
|
|
|
|
static func shake(millseconds: float, intensity: float = 10, steper: Callable = func(currentValue, _totalValue, _restPercent): return currentValue):
|
|
var startTime = WorldManager.getTime()
|
|
instance.shakeIntensity = intensity
|
|
await TickTool.until(
|
|
func():
|
|
instance.shakeIntensity = steper.call(instance.shakeIntensity, intensity, 1 - (WorldManager.getTime() - startTime) / millseconds)
|
|
return WorldManager.getTime() - startTime >= millseconds
|
|
)
|
|
instance.shakeIntensity = 0
|
|
static func playAnimation(animation: String):
|
|
instance.animator.play(animation)
|