Skip to content

Commit

Permalink
1.3.0 feat: Implemented screen controls for mobile responsivity
Browse files Browse the repository at this point in the history
  • Loading branch information
PBertotti committed Apr 22, 2021
1 parent f0837d0 commit f5de844
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions falarya-app/src/scenes/board/board.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,43 @@ class board extends phaser.Scene {
? this.scale.startFullscreen()
: this.scale.stopFullscreen();
});

console.log(window.innerWidth)
if (window.innerWidth < 1000){
this.mobileBtnUp = this.add
.rectangle(100, 500, 50, 50, "black", 70)
.setInteractive()
.on("pointerdown", () => {
this.player.body.touching.down && this.player.setVelocityY(2000);
this.socket.emit("player_moved", {
id: this.socket.id,
move: "player_jumped",
});
});

this.mobileBtnRight = this.add
.rectangle(150, 550, 50, 50, "black", 70)
.setInteractive()
.on("pointerdown", () => {
this.player.setVelocityX(200);
this.socket.emit("player_moved", {
id: this.socket.id,
move: "player_moved_right",
});
});

this.mobileBtnLeft = this.add
.rectangle(50, 550, 50, 50, "black", 70)
.setInteractive()
.on("pointerdown", () => {
this.player.setVelocityX(-200);
this.socket.emit("player_moved", {
id: this.socket.id,
move: "player_moved_left",
});
});
}

}
// -------------------------

Expand Down

0 comments on commit f5de844

Please sign in to comment.