Improved hair animation

This commit is contained in:
2024-12-20 01:28:48 +01:00
parent 03313cb092
commit 5eabb39ec8
4 changed files with 34 additions and 28 deletions

View File

@ -3,7 +3,7 @@
<Healthbar :zoneCharacter="props.zoneCharacter" :currentX="currentX" :currentY="currentY" />
<Container ref="charContainer" :depth="isometricDepth" :x="currentX" :y="currentY">
<CharacterHair :zoneCharacter="props.zoneCharacter" :currentX="currentX" :currentY="currentY" />
<Sprite ref="charSprite" :origin-y="1" :flipX="isFlippedX" :flipY="false" />
<Sprite ref="charSprite" :origin-y="1" :flipX="isFlippedX" />
</Container>
</template>

View File

@ -27,11 +27,14 @@ const texture = computed(() => {
})
const isFlippedX = computed(() => [6, 4].includes(props.zoneCharacter.character.rotation ?? 0))
const ANIMATION_MS = 500 // Animation duration in milliseconds
const imageProps = computed(() => ({
depth: 1,
originY: [0, 6].includes(props.zoneCharacter.character.rotation ?? 0) ? 4.30 : 5.25,
originY: [0, 6].includes(props.zoneCharacter.character.rotation ?? 0) ? 4.30 : 5.30,
flipX: isFlippedX.value,
texture: texture.value
texture: texture.value,
y: props.zoneCharacter.isMoving ? (scene.time.now % ANIMATION_MS < (ANIMATION_MS / 2) ? 1 : 0) : 0,
}))