Merge branch 'walking-shortest-path' into feature-move-character-api
This commit is contained in:
commit
f96eac4737
1
front/.gitignore
vendored
1
front/.gitignore
vendored
@ -6,6 +6,7 @@
|
|||||||
/dist/main.*.css.map
|
/dist/main.*.css.map
|
||||||
/dist/tests/
|
/dist/tests/
|
||||||
/yarn-error.log
|
/yarn-error.log
|
||||||
|
/package-lock.json
|
||||||
/dist/webpack.config.js
|
/dist/webpack.config.js
|
||||||
/dist/webpack.config.js.map
|
/dist/webpack.config.js.map
|
||||||
/dist/src
|
/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
|
deltaZ: number
|
||||||
) => void;
|
) => void;
|
||||||
handlePointerUpEvent: (pointer: Phaser.Input.Pointer, gameObjects: Phaser.GameObjects.GameObject[]) => 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;
|
handleSpaceKeyUpEvent: (event: Event) => Event;
|
||||||
}
|
}
|
||||||
|
@ -40,30 +40,22 @@ export class MobileJoystick extends VirtualJoystick {
|
|||||||
this.visible = false;
|
this.visible = false;
|
||||||
this.enable = 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.resizeCallback = this.resize.bind(this);
|
||||||
this.scene.scale.on(Phaser.Scale.Events.RESIZE, this.resizeCallback);
|
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() {
|
public resize() {
|
||||||
this.base.setDisplaySize(this.getDisplaySizeByElement(baseSize), this.getDisplaySizeByElement(baseSize));
|
this.base.setDisplaySize(this.getDisplaySizeByElement(baseSize), this.getDisplaySizeByElement(baseSize));
|
||||||
this.thumb.setDisplaySize(this.getDisplaySizeByElement(thumbSize), this.getDisplaySizeByElement(thumbSize));
|
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 {
|
public handlePointerUpEvent(pointer: Phaser.Input.Pointer, gameObjects: Phaser.GameObjects.GameObject[]): void {
|
||||||
if (pointer.rightButtonReleased()) {
|
if (pointer.rightButtonReleased() || pointer.getDuration() > 250) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const camera = this.gameScene.getCameraManager().getCamera();
|
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 {
|
public handleSpaceKeyUpEvent(event: Event): Event {
|
||||||
this.gameScene.activateOutlinedItem();
|
this.gameScene.activateOutlinedItem();
|
||||||
return event;
|
return event;
|
||||||
|
@ -253,10 +253,27 @@ export class UserInputManager {
|
|||||||
this.scene.input.on(
|
this.scene.input.on(
|
||||||
Phaser.Input.Events.POINTER_UP,
|
Phaser.Input.Events.POINTER_UP,
|
||||||
(pointer: Phaser.Input.Pointer, gameObjects: Phaser.GameObjects.GameObject[]) => {
|
(pointer: Phaser.Input.Pointer, gameObjects: Phaser.GameObjects.GameObject[]) => {
|
||||||
|
this.joystick.hide();
|
||||||
this.userInputHandler.handlePointerUpEvent(pointer, gameObjects);
|
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.scene.input.keyboard.on("keyup-SPACE", (event: Event) => {
|
||||||
this.userInputHandler.handleSpaceKeyUpEvent(event);
|
this.userInputHandler.handleSpaceKeyUpEvent(event);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user