#146 : Set camera on player's position after loading into a zone
This commit is contained in:
parent
334ceaa8f3
commit
16a8435f7b
@ -22,7 +22,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, useGame } from 'phavuer'
|
||||
import { Container, refObj, RoundRectangle, Sprite, Text, useGame, useScene } from 'phavuer'
|
||||
import { calculateIsometricDepth, tileToWorldX, tileToWorldY } from '@/composables/zoneComposable'
|
||||
|
||||
enum Direction {
|
||||
@ -43,6 +43,7 @@ const charSprite = refObj<Phaser.GameObjects.Sprite>()
|
||||
const game = useGame()
|
||||
const gameStore = useGameStore()
|
||||
const zoneStore = useZoneStore()
|
||||
const scene = useScene()
|
||||
|
||||
const currentX = ref(0)
|
||||
const currentY = ref(0)
|
||||
@ -177,6 +178,10 @@ onMounted(() => {
|
||||
|
||||
if (props.character.id === gameStore.character!.id) {
|
||||
zoneStore.setCharacterLoaded(true)
|
||||
|
||||
// #146 : Set camera position to character, need to be improved still
|
||||
scene.cameras.main.startFollow(charContainer.value as Phaser.GameObjects.Container)
|
||||
scene.cameras.main.stopFollow()
|
||||
}
|
||||
|
||||
// Set sprite
|
||||
|
@ -8,7 +8,7 @@
|
||||
import { useScene } from 'phavuer'
|
||||
import { useGameStore } from '@/stores/gameStore'
|
||||
import { useZoneStore } from '@/stores/zoneStore'
|
||||
import { onBeforeMount, onBeforeUnmount, onMounted, ref } from 'vue'
|
||||
import { onBeforeMount, onBeforeUnmount, ref } from 'vue'
|
||||
import type { Character as CharacterT, Zone as ZoneT, ExtendedCharacter as ExtendedCharacterT } from '@/types'
|
||||
import Tiles from '@/components/zone/Tiles.vue'
|
||||
import Objects from '@/components/zone/Objects.vue'
|
||||
|
Loading…
x
Reference in New Issue
Block a user