forked from noxious/client
Improved moving
This commit is contained in:
parent
d80733a597
commit
522b4958b5
@ -56,12 +56,15 @@ const updatePosition = (x: number, y: number) => {
|
||||
tween.value.stop()
|
||||
}
|
||||
|
||||
const distance = Math.sqrt(Math.pow(targetX - currentX.value, 2) + Math.pow(targetY - currentY.value, 2))
|
||||
const duration = distance * 5 // Adjust this multiplier to control overall speed
|
||||
|
||||
tween.value = props.layer.scene.tweens.add({
|
||||
targets: { x: currentX.value, y: currentY.value },
|
||||
x: targetX,
|
||||
y: targetY,
|
||||
duration: 160,
|
||||
ease: 'Power1',
|
||||
duration: duration,
|
||||
ease: 'Linear',
|
||||
onUpdate: (tween) => {
|
||||
currentX.value = tween.targets[0].x ?? 0
|
||||
currentY.value = tween.targets[0].y ?? 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user