Spawn anim bug fix
This commit is contained in:
parent
522b4958b5
commit
7064c7b7f3
@ -47,11 +47,19 @@ const props = withDefaults(defineProps<Props>(), {
|
|||||||
const currentX = ref(0)
|
const currentX = ref(0)
|
||||||
const currentY = ref(0)
|
const currentY = ref(0)
|
||||||
const tween = ref<Phaser.Tweens.Tween | null>(null)
|
const tween = ref<Phaser.Tweens.Tween | null>(null)
|
||||||
|
const isInitialPosition = ref(true)
|
||||||
|
|
||||||
const updatePosition = (x: number, y: number) => {
|
const updatePosition = (x: number, y: number) => {
|
||||||
const targetX = tileToWorldX(props.layer, x, y)
|
const targetX = tileToWorldX(props.layer, x, y)
|
||||||
const targetY = tileToWorldY(props.layer, x, y)
|
const targetY = tileToWorldY(props.layer, x, y)
|
||||||
|
|
||||||
|
if (isInitialPosition.value) {
|
||||||
|
currentX.value = targetX
|
||||||
|
currentY.value = targetY
|
||||||
|
isInitialPosition.value = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (tween.value && tween.value.isPlaying()) {
|
if (tween.value && tween.value.isPlaying()) {
|
||||||
tween.value.stop()
|
tween.value.stop()
|
||||||
}
|
}
|
||||||
@ -72,10 +80,12 @@ const updatePosition = (x: number, y: number) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(() => props.character, (newChar) => {
|
watch(() => props.character, (newChar, oldChar) => {
|
||||||
if (newChar) {
|
if (newChar) {
|
||||||
|
if (!oldChar || newChar.position_x !== oldChar.position_x || newChar.position_y !== oldChar.position_y) {
|
||||||
updatePosition(newChar.position_x, newChar.position_y)
|
updatePosition(newChar.position_x, newChar.position_y)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}, { immediate: true, deep: true })
|
}, { immediate: true, deep: true })
|
||||||
|
|
||||||
const charTexture = computed(() => {
|
const charTexture = computed(() => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user