This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//#region Experiment Vector | |
const p1 = new Phaser.Math.Vector2(); | |
this.input.on('pointerdown', (event: MouseEvent) => { | |
p1.x = event.x; | |
p1.y = event.y; | |
}); | |
const p2 = new Phaser.Math.Vector2(); | |
this.input.on('pointerup', (event: MouseEvent) => { | |
p2.x = event.x; | |
p2.y = event.y; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class VirtualJoystick extends Phaser.GameObjects.Sprite { | |
constructor(scene, x, y, {texture, container, controlled}) { | |
super(scene, x, y, container); | |
scene.add.existing(this); | |
this._touchStart = false; | |
this._threshold = 45; | |
this._startPos = { x: x, y: y }; | |
this._controller = scene.add.sprite(x, y, texture); | |
this._controlled = controlled; |