Last active
March 30, 2020 15:39
-
-
Save ReydVires/e94e24d6fe2443ece7171952782ba6fb to your computer and use it in GitHub Desktop.
Vector_in_Nutshell.ts
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; | |
console.log("Data p2", p2); | |
console.log("Data p1", p1); | |
const p3 = p2.subtract(p1); | |
this._player.setPosition(this._player.x + p3.x, this._player.y + p3.y); | |
console.log("Dir", p3.normalize()); | |
}); | |
//#endregion |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment