1
0
forked from noxious/client

Centered camera & Modal position changes

- Able to give position to modal other then centered.
 - Camera now centered on character when
   - Character joins zone
   - Character teleports on to zone
   - Window resize
This commit is contained in:
Zaxiure
2024-09-21 12:00:49 +02:00
parent cfb3e427cf
commit d0bf622443
6 changed files with 95 additions and 8 deletions

View File

@ -6,6 +6,15 @@ export function useCameraControls(scene: Phaser.Scene): any {
const camera = ref(scene.cameras.main)
const isDragging = ref(false)
// Resize center camera on character.
window.addEventListener('resize', () => {
console.log('woep')
// Need to change camera position next frame
setTimeout(() => {
scene.cameras.main.setScroll(-(scene.cameras.main.worldView.width/2) + gameStore.character.relativePosition.x, -(scene.cameras.main.worldView.height/2) + gameStore.character.relativePosition.y)
}, 0)
})
function onPointerDown(pointer: Phaser.Input.Pointer) {
if (pointer.event instanceof MouseEvent || pointer.event.shiftKey) {
isDragging.value = true