cr fixes
This commit is contained in:
parent
e0e1a7e76a
commit
9e5d8f5d9c
1
front/.gitignore
vendored
1
front/.gitignore
vendored
@ -6,6 +6,7 @@
|
||||
/dist/main.*.css.map
|
||||
/dist/tests/
|
||||
/yarn-error.log
|
||||
/package-lock.json
|
||||
/dist/webpack.config.js
|
||||
/dist/webpack.config.js.map
|
||||
/dist/src
|
||||
|
9550
front/package-lock.json
generated
9550
front/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -7,5 +7,6 @@ export interface UserInputHandlerInterface {
|
||||
deltaZ: number
|
||||
) => void;
|
||||
handlePointerUpEvent: (pointer: Phaser.Input.Pointer, gameObjects: Phaser.GameObjects.GameObject[]) => void;
|
||||
handlePointerDownEvent: (pointer: Phaser.Input.Pointer, gameObjects: Phaser.GameObjects.GameObject[]) => void;
|
||||
handleSpaceKeyUpEvent: (event: Event) => Event;
|
||||
}
|
||||
|
@ -40,30 +40,22 @@ export class MobileJoystick extends VirtualJoystick {
|
||||
this.visible = false;
|
||||
this.enable = false;
|
||||
|
||||
this.scene.input.on("pointerdown", (pointer: Phaser.Input.Pointer) => {
|
||||
if (!pointer.wasTouch) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Let's only display the joystick if there is one finger on the screen
|
||||
if ((pointer.event as TouchEvent).touches.length === 1) {
|
||||
this.x = pointer.x;
|
||||
this.y = pointer.y;
|
||||
this.visible = true;
|
||||
this.enable = true;
|
||||
} else {
|
||||
this.visible = false;
|
||||
this.enable = false;
|
||||
}
|
||||
});
|
||||
this.scene.input.on("pointerup", () => {
|
||||
this.visible = false;
|
||||
this.enable = false;
|
||||
});
|
||||
this.resizeCallback = this.resize.bind(this);
|
||||
this.scene.scale.on(Phaser.Scale.Events.RESIZE, this.resizeCallback);
|
||||
}
|
||||
|
||||
public showAt(x: number, y: number): void {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.visible = true;
|
||||
this.enable = true;
|
||||
}
|
||||
|
||||
public hide(): void {
|
||||
this.visible = false;
|
||||
this.enable = false;
|
||||
}
|
||||
|
||||
public resize() {
|
||||
this.base.setDisplaySize(this.getDisplaySizeByElement(baseSize), this.getDisplaySizeByElement(baseSize));
|
||||
this.thumb.setDisplaySize(this.getDisplaySizeByElement(thumbSize), this.getDisplaySizeByElement(thumbSize));
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user