1
0
forked from noxious/client

Improved moving

This commit is contained in:
Dennis Postma 2024-08-17 20:42:28 +02:00
parent d80733a597
commit 522b4958b5

View File

@ -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