Skip to content

Instantly share code, notes, and snippets.

View ReydVires's full-sized avatar
⚔️
Code-Knight

Arsyel ReydVires

⚔️
Code-Knight
  • Jakarta
View GitHub Profile
@ReydVires
ReydVires / Vector_in_Nutshell.ts
Last active March 30, 2020 15:39
Vector_in_Nutshell.ts
//#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;
@ReydVires
ReydVires / VirtualJoystick.js
Last active October 19, 2019 11:05
How To Create VirtualJoystick with Phaser 3
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;