From a92675e4c0e053566c18f35fec027c80e5682442 Mon Sep 17 00:00:00 2001 From: Dennis Postma Date: Sat, 28 Sep 2024 17:46:05 +0200 Subject: [PATCH] Position fix for texts --- package-lock.json | 6 +++--- src/components/sprites/Character.vue | 17 ++++++++++++++--- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 74b1c43..feeb199 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6115,9 +6115,9 @@ "license": "MIT" }, "node_modules/sass": { - "version": "1.79.3", - "resolved": "https://registry.npmjs.org/sass/-/sass-1.79.3.tgz", - "integrity": "sha512-m7dZxh0W9EZ3cw50Me5GOuYm/tVAJAn91SUnohLRo9cXBixGUOdvmryN+dXpwR831bhoY3Zv7rEFt85PUwTmzA==", + "version": "1.79.4", + "resolved": "https://registry.npmjs.org/sass/-/sass-1.79.4.tgz", + "integrity": "sha512-K0QDSNPXgyqO4GZq2HO5Q70TLxTH6cIT59RdoCHMivrC8rqzaTw5ab9prjz9KUN1El4FLXrBXJhik61JR4HcGg==", "dev": true, "license": "MIT", "dependencies": { diff --git a/src/components/sprites/Character.vue b/src/components/sprites/Character.vue index 95e216c..e88cecc 100644 --- a/src/components/sprites/Character.vue +++ b/src/components/sprites/Character.vue @@ -19,7 +19,7 @@ import { type ExtendedCharacter } from '@/types' import { useGameStore } from '@/stores/gameStore' import { useZoneStore } from '@/stores/zoneStore' import { watch, computed, ref, onMounted, onUnmounted } from 'vue' -import { Container, refObj, RoundRectangle, Sprite, Text } from 'phavuer' +import { Container, refObj, RoundRectangle, Sprite, Text, useGame } from 'phavuer' import { calculateIsometricDepth, tileToWorldX, tileToWorldY } from '@/composables/zoneComposable' enum Direction { @@ -37,14 +37,15 @@ const charChatContainer = refObj() const charContainer = refObj() const charSprite = refObj() +const game = useGame() const gameStore = useGameStore() const zoneStore = useZoneStore() -const isometricDepth = ref(1) const currentX = ref(0) const currentY = ref(0) -const tween = ref(null) +const isometricDepth = ref(1) const isInitialPosition = ref(true) +const tween = ref(null) const updateIsometricDepth = (x: number, y: number) => { isometricDepth.value = calculateIsometricDepth(x, y, 28, 94, true) @@ -135,11 +136,21 @@ const createChatText = (text: Phaser.GameObjects.Text) => { text.setFontSize(13) text.setFontStyle('bold') text.setFontFamily('Arial') + + // Fix text alignment on Windows + if (game.device.os.windows) { + text.setOrigin(0.5, 9.8) + } } const createText = (text: Phaser.GameObjects.Text) => { text.setFontSize(13) text.setFontFamily('Arial') + + // Fix text alignment on Windows + if (game.device.os.windows) { + text.setOrigin(0.5, 8) + } } watch(