1
0
forked from noxious/client

small logic improvement

This commit is contained in:
Dennis Postma 2024-06-13 23:21:24 +02:00
parent ad94928370
commit a308696cf2
2 changed files with 12 additions and 3 deletions

View File

@ -66,8 +66,10 @@ watch(drawMode, (value) => {
zoneEditorStore.setDrawMode(value) zoneEditorStore.setDrawMode(value)
}) })
function drawTiles(pointer: Phaser.Input.Pointer) { function drawTile(pointer: Phaser.Input.Pointer) {
if (!pointer.isDown) return if (zoneEditorStore.tool !== 'eraser' && zoneEditorStore.tool !== 'pencil') {
return
}
const px = scene.cameras.main.worldView.x + pointer.x const px = scene.cameras.main.worldView.x + pointer.x
const py = scene.cameras.main.worldView.y + pointer.y const py = scene.cameras.main.worldView.y + pointer.y
@ -86,9 +88,16 @@ function drawTiles(pointer: Phaser.Input.Pointer) {
} }
} }
function drawTiles(pointer: Phaser.Input.Pointer) {
if (!pointer.isDown) return
drawTile(pointer)
}
scene.input.on(Phaser.Input.Events.POINTER_UP, drawTile)
scene.input.on(Phaser.Input.Events.POINTER_MOVE, drawTiles) scene.input.on(Phaser.Input.Events.POINTER_MOVE, drawTiles)
onBeforeUnmount(() => { onBeforeUnmount(() => {
scene.input.off(Phaser.Input.Events.POINTER_UP, drawTile)
scene.input.off(Phaser.Input.Events.POINTER_MOVE, drawTiles) scene.input.off(Phaser.Input.Events.POINTER_MOVE, drawTiles)
}) })

View File

@ -53,7 +53,7 @@ const gameConfig = {
name: 'New Quest', name: 'New Quest',
width: window.innerWidth, width: window.innerWidth,
height: window.innerHeight, height: window.innerHeight,
type: Phaser.CANVAS, type: Phaser.AUTO,
pixelArt: true pixelArt: true
} }