Various zone editor UX improvements

This commit is contained in:
2024-07-11 18:28:38 +02:00
parent f830bf875e
commit ea9771e3ec
5 changed files with 27 additions and 1 deletions

View File

@ -64,6 +64,25 @@ watch(
{ deep: true }
)
// if ctrl is pressed and mouse is down , then drag the zone
scene.input.on(Phaser.Input.Events.POINTER_DOWN, (pointer: Phaser.Input.Pointer) => {
if (pointer.event.altKey) {
scene.input.on(Phaser.Input.Events.POINTER_MOVE, dragZone)
} else if (zoneEditorStore.tool !== 'move') {
scene.input.off(Phaser.Input.Events.POINTER_MOVE, dragZone)
}
})
/**
* Zoom in and out
*/
scene.input.on(Phaser.Input.Events.POINTER_WHEEL, (pointer: Phaser.Input.Pointer, gameObjects: Phaser.GameObjects.GameObject[], deltaX: number, deltaY: number) => {
if (pointer.event.altKey) {
scene.scale.setZoom(scene.scale.zoom - deltaY * 0.01)
cam = scene.cameras.main
}
})
// Unload funcs
onBeforeUnmount(() => {
scene.input.off(Phaser.Input.Events.POINTER_MOVE, onPointerMove)