1
0
forked from noxious/client

Added container for character for easier X and Y coord handling

This commit is contained in:
2025-02-01 15:27:14 +01:00
parent e4b9bb4d61
commit af26ca5e89
5 changed files with 33 additions and 36 deletions

View File

@ -1,8 +1,10 @@
<template>
<ChatBubble :mapCharacter="props.mapCharacter" :currentX="currentPositionX" :currentY="currentPositionY" />
<HealthBar :mapCharacter="props.mapCharacter" :currentX="currentPositionX" :currentY="currentPositionY" />
<CharacterHair :mapCharacter="props.mapCharacter" :currentX="currentPositionX" :currentY="currentPositionY" />
<Sprite ref="charSprite" :depth="isometricDepth" :x="currentPositionX" :y="currentPositionY" :origin-y="1" :flipX="isFlippedX" />
<Container ref="characterContainer" :x="currentPositionX" :y="currentPositionY">
<ChatBubble :mapCharacter="props.mapCharacter" />
<HealthBar :mapCharacter="props.mapCharacter" />
<CharacterHair :mapCharacter="props.mapCharacter" />
<Sprite ref="characterSprite" :depth="isometricDepth" :origin-y="1" :flipX="isFlippedX" />
</Container>
</template>
<script lang="ts" setup>
@ -13,7 +15,7 @@ import HealthBar from '@/components/game/character/partials/HealthBar.vue'
import { useCharacterSprite } from '@/composables/useCharacterSpriteComposable'
import { useGameStore } from '@/stores/gameStore'
import { useMapStore } from '@/stores/mapStore'
import { Sprite, useScene } from 'phavuer'
import { Container, Sprite, useScene } from 'phavuer'
import { onMounted, onUnmounted, watch } from 'vue'
import { Direction } from '@/application/enums'
@ -27,7 +29,8 @@ const mapStore = useMapStore()
const scene = useScene()
const {
charSprite,
characterContainer,
characterSprite,
currentPositionX,
currentPositionY,
isometricDepth,
@ -68,7 +71,7 @@ onMounted(async () => {
if (props.mapCharacter.character.id === gameStore.character!.id) {
mapStore.setCharacterLoaded(true)
scene.cameras.main.startFollow(charSprite.value as Phaser.GameObjects.Sprite)
scene.cameras.main.startFollow(characterContainer.value as Phaser.GameObjects.Container)
}
})

View File

@ -12,8 +12,6 @@ import { computed, onMounted, ref } from 'vue'
const props = defineProps<{
mapCharacter: MapCharacter
currentX: number
currentY: number
}>()
const gameStore = useGameStore()
@ -39,9 +37,7 @@ const imageProps = computed(() => {
originX: Number(spriteAction?.originX) ?? 0,
originY: Number(spriteAction?.originY) ?? 0,
flipX: isFlippedX.value,
texture: texture.value,
y: props.currentY,
x: props.currentX
texture: texture.value
}
})

View File

@ -1,5 +1,5 @@
<template>
<Container ref="charChatContainer" :depth="999" :x="currentX" :y="currentY">
<Container ref="charChatContainer" :depth="999">
<RoundRectangle @create="createChatBubble" :origin-x="0.5" :origin-y="7.5" :fillColor="0xffffff" :width="194" :height="21" :radius="20" />
<Text @create="createChatText" :style="{ fontSize: 13, fontFamily: 'Arial', color: '#000' }" />
</Container>
@ -12,8 +12,6 @@ import { onMounted } from 'vue'
const props = defineProps<{
mapCharacter: MapCharacter
currentX: number
currentY: number
}>()
const game = useGame()

View File

@ -1,5 +1,5 @@
<template>
<Container :depth="999" :x="currentX" :y="currentY">
<Container :depth="999">
<Text @create="createNicknameText" :text="props.mapCharacter.character.name" />
<RoundRectangle :origin-x="0.5" :origin-y="18.5" :fillColor="0xffffff" :width="74" :height="6" :radius="5" />
<RoundRectangle :origin-x="0.5" :origin-y="36.4" :fillColor="0x00b3b3" :width="70" :height="3" :radius="5" />
@ -12,8 +12,6 @@ import { Container, RoundRectangle, Text, useGame } from 'phavuer'
const props = defineProps<{
mapCharacter: MapCharacter
currentX: number
currentY: number
}>()
const game = useGame()