Improving pinch (virtual joystick stops when pinch begins)

This commit is contained in:
David Négrier
2021-05-05 09:35:24 +02:00
parent 59b391e983
commit f66e69cb75
5 changed files with 70 additions and 30 deletions
@@ -3,6 +3,7 @@ import {GameScene} from "../Game/GameScene";
import {touchScreenManager} from "../../Touch/TouchScreenManager";
import {MobileJoystick} from "../Components/MobileJoystick";
import MouseWheelToUpDown from 'phaser3-rex-plugins/plugins/mousewheeltoupdown.js';
import {waScaleManager} from "../Services/WaScaleManager";
interface UserInputManagerDatum {
keyInstance: Phaser.Input.Keyboard.Key;
@@ -55,6 +56,7 @@ export class UserInputManager {
this.Scene = Scene;
this.isInputDisabled = false;
this.initKeyBoardEvent();
this.initMouseWheel();
if (touchScreenManager.supportTouchScreen) {
this.initVirtualJoystick();
}
@@ -175,4 +177,10 @@ export class UserInputManager {
destroy(): void {
this.joystick.destroy();
}
private initMouseWheel() {
this.Scene.input.on('wheel', (pointer: unknown, gameObjects: unknown, deltaX: number, deltaY: number, deltaZ: number) => {
this.Scene.zoomByFactor(1 - deltaY / 53 * 0.1);
});
}
}