Melonjs Tutorial <Original • Edition>

return true; }

update(dt) { if (me.input.isKeyPressed("left")) { this.body.force.x = -4; } else if (me.input.isKeyPressed("right")) { this.body.force.x = 4; } melonjs tutorial

Now run the game. Move your orange square into the gold squares – they disappear and you get a console log. Create src/js/ui/ScoreLabel.js : return true; } update(dt) { if (me

import me from "melong-js"; export default class ScoreLabel extends me.Renderable { constructor() { super(10, 10, 100, 50); this.score = 0; this.font = new me.Font("Arial", 24, "#FFFFFF"); } this.score = 0

In your PlayScene:

this.body.update(dt); this.pos.x += this.body.vel.x; this.pos.y += this.body.vel.y;

Now register this entity in your main scene ( src/js/scenes/PlayScene.js ):