From a0da0266d331f07d8c3417bd2c5426a7e6bf39ae Mon Sep 17 00:00:00 2001 From: Dennis Postma Date: Wed, 19 Feb 2025 01:33:38 +0100 Subject: [PATCH] Revert logic, updated preview --- src/components/game/character/Character.vue | 9 +++---- .../game/character/partials/CharacterHair.vue | 12 ++++++---- .../characterHair/CharacterHairDetails.vue | 24 ++++++++++--------- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/src/components/game/character/Character.vue b/src/components/game/character/Character.vue index c8b6cd5..126ad53 100644 --- a/src/components/game/character/Character.vue +++ b/src/components/game/character/Character.vue @@ -2,7 +2,7 @@ - + @@ -28,7 +28,7 @@ const gameStore = useGameStore() const mapStore = useMapStore() const scene = useScene() -const { characterContainer, characterSprite, getSpriteHeightByAction, currentPositionX, currentPositionY, isometricDepth, isFlippedX, updatePosition, playAnimation, updateSprite, initializeSprite, cleanup } = useCharacterSpriteComposable(scene, props.tileMap, props.mapCharacter) +const { characterContainer, characterSprite, currentPositionX, currentPositionY, isometricDepth, isFlippedX, updatePosition, playAnimation, updateSprite, initializeSprite, cleanup } = useCharacterSpriteComposable(scene, props.tileMap, props.mapCharacter) const { playSound, stopSound } = useSoundComposable() const handlePositionUpdate = (newValues: any, oldValues: any) => { @@ -43,8 +43,6 @@ const handlePositionUpdate = (newValues: any, oldValues: any) => { } } -const currentSpriteHeight = ref(0) - /** * Plays walk sound when character is moving */ @@ -86,14 +84,13 @@ watch( rotation: props.mapCharacter.character.rotation, isAttacking: props.mapCharacter.isAttacking }), - (oldValues, newValues) => { + async (oldValues, newValues) => { handlePositionUpdate(oldValues, newValues) } ) onMounted(async () => { await initializeSprite() - currentSpriteHeight.value = await getSpriteHeightByAction('idle_left_up') if (props.mapCharacter.character.id === gameStore.character!.id) { scene.cameras.main.startFollow(characterContainer.value as Phaser.GameObjects.Container) diff --git a/src/components/game/character/partials/CharacterHair.vue b/src/components/game/character/partials/CharacterHair.vue index ad758d0..2e4de3f 100644 --- a/src/components/game/character/partials/CharacterHair.vue +++ b/src/components/game/character/partials/CharacterHair.vue @@ -12,7 +12,6 @@ import { computed, onMounted, ref } from 'vue' const props = defineProps<{ mapCharacter: MapCharacter - spriteHeight: number }>() const gameStore = useGameStore() @@ -30,12 +29,15 @@ const texture = computed(() => { const isFlippedX = computed(() => [6, 4].includes(props.mapCharacter.character.rotation ?? 0)) const imageProps = computed(() => { + const direction = [0, 6].includes(props.mapCharacter.character.rotation ?? 0) ? 'back' : 'front' + const spriteAction = sprite.value?.spriteActions?.find((spriteAction) => spriteAction.action === direction) + return { - originX: 0.5, - originY: 0.32 / 1.8, // 32 height + depth: 9999, + originX: Number(spriteAction?.originX) ?? 0, + originY: Number(spriteAction?.originY) ?? 0, flipX: isFlippedX.value, - texture: texture.value, - y: -props.spriteHeight + texture: texture.value } }) diff --git a/src/components/gameMaster/assetManager/partials/characterHair/CharacterHairDetails.vue b/src/components/gameMaster/assetManager/partials/characterHair/CharacterHairDetails.vue index d1bfea9..3d1bf13 100644 --- a/src/components/gameMaster/assetManager/partials/characterHair/CharacterHairDetails.vue +++ b/src/components/gameMaster/assetManager/partials/characterHair/CharacterHairDetails.vue @@ -20,27 +20,29 @@
+
+ + +
+
+
+
-
-
-

Preview

-
+
+
+ +
+
+
-
-
- - -
-
-