This commit is contained in:
Hanusiak Piotr 2022-01-19 10:37:56 +01:00
parent e0e1a7e76a
commit 9e5d8f5d9c
6 changed files with 34 additions and 9571 deletions

View file

@ -19,7 +19,7 @@ export class GameSceneUserInputHandler implements UserInputHandlerInterface {
}
public handlePointerUpEvent(pointer: Phaser.Input.Pointer, gameObjects: Phaser.GameObjects.GameObject[]): void {
if (pointer.rightButtonReleased()) {
if (pointer.rightButtonReleased() || pointer.getDuration() > 250) {
return;
}
const camera = this.gameScene.getCameraManager().getCamera();
@ -49,6 +49,8 @@ export class GameSceneUserInputHandler implements UserInputHandlerInterface {
});
}
public handlePointerDownEvent(pointer: Phaser.Input.Pointer, gameObjects: Phaser.GameObjects.GameObject[]): void {}
public handleSpaceKeyUpEvent(event: Event): Event {
this.gameScene.activateOutlinedItem();
return event;

View file

@ -253,10 +253,27 @@ export class UserInputManager {
this.scene.input.on(
Phaser.Input.Events.POINTER_UP,
(pointer: Phaser.Input.Pointer, gameObjects: Phaser.GameObjects.GameObject[]) => {
this.joystick.hide();
this.userInputHandler.handlePointerUpEvent(pointer, gameObjects);
}
);
this.scene.input.on(
Phaser.Input.Events.POINTER_DOWN,
(pointer: Phaser.Input.Pointer, gameObjects: Phaser.GameObjects.GameObject[]) => {
if (!pointer.wasTouch) {
return;
}
this.userInputHandler.handlePointerDownEvent(pointer, gameObjects);
// Let's only display the joystick if there is one finger on the screen
if ((pointer.event as TouchEvent).touches.length === 1) {
this.joystick.showAt(pointer.x, pointer.y);
} else {
this.joystick.hide();
}
}
);
this.scene.input.keyboard.on("keyup-SPACE", (event: Event) => {
this.userInputHandler.handleSpaceKeyUpEvent(event);
});