mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-28 06:51:54 +08:00
feat(相机): 添加鼠标位置对相机偏移的影响
实现鼠标位置影响相机偏移的功能,使相机能够根据鼠标在屏幕上的位置进行轻微偏移,提升游戏交互体验
This commit is contained in:
@@ -86,6 +86,8 @@ limit_top = -1800
|
|||||||
limit_right = 2400
|
limit_right = 2400
|
||||||
limit_bottom = 1800
|
limit_bottom = 1800
|
||||||
position_smoothing_enabled = true
|
position_smoothing_enabled = true
|
||||||
|
drag_horizontal_enabled = true
|
||||||
|
drag_vertical_enabled = true
|
||||||
editor_draw_limits = true
|
editor_draw_limits = true
|
||||||
script = ExtResource("5_mk7bv")
|
script = ExtResource("5_mk7bv")
|
||||||
constantOffset = Vector2(0, -80)
|
constantOffset = Vector2(0, -80)
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ func _physics_process(_delta):
|
|||||||
if is_instance_valid(UIState.player):
|
if is_instance_valid(UIState.player):
|
||||||
position = UIState.player.position + constantOffset
|
position = UIState.player.position + constantOffset
|
||||||
position += MathTool.sampleInCircle(shakeIntensity)
|
position += MathTool.sampleInCircle(shakeIntensity)
|
||||||
|
position += MouseTool.getPositionByScreen(Vector2.ONE * 0.5, self ) / 2
|
||||||
|
|
||||||
static func shake(millseconds: float, intensity: float = 10, steper: Callable = func(currentValue, _totalValue, _restPercent): return currentValue):
|
static func shake(millseconds: float, intensity: float = 10, steper: Callable = func(currentValue, _totalValue, _restPercent): return currentValue):
|
||||||
if StarterPanel.buildingShader: return
|
if StarterPanel.buildingShader: return
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
class_name MouseTool
|
||||||
|
|
||||||
|
static func getPositionByScreen(anchor: Vector2, by: Node):
|
||||||
|
var viewport = by.get_viewport()
|
||||||
|
return viewport.get_mouse_position() - viewport.get_visible_rect().size * anchor
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://yf2h5ni3gobm
|
||||||
Reference in New Issue
Block a user