This commit is contained in:
Smile Rex
2026-01-21 18:30:37 +03:00
parent 77fa4cbd03
commit 29f2e0b165
28 changed files with 1515 additions and 1574 deletions

26
src/input/TouchInput.ts Normal file
View File

@@ -0,0 +1,26 @@
import Phaser from "phaser";
export class TouchInput {
dx = 0;
dy = 0;
constructor(scene: Phaser.Scene) {
let start: Phaser.Math.Vector2 | null = null;
scene.input.on("pointerdown", (pointer: Phaser.Input.Pointer) => {
start = new Phaser.Math.Vector2(pointer.x, pointer.y);
});
scene.input.on("pointermove", (pointer: Phaser.Input.Pointer) => {
if (!start) return;
this.dx = Phaser.Math.Clamp((pointer.x - start.x) / 50, -1, 1);
this.dy = Phaser.Math.Clamp((pointer.y - start.y) / 50, -1, 1);
});
scene.input.on("pointerup", () => {
start = null;
this.dx = 0;
this.dy = 0;
});
}
}