Melonjs Tutorial — ((hot))

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"); }

// Default color (temporary) this.color = "#FF5722"; }

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 : melonjs tutorial

Now spawn 10 collectibles in your PlayScene:

import me from "melong-js"; export default class Collectible extends me.Entity { constructor(x, y) { super(x, y, { width: 16, height: 16 }); this.color = "#FFD700"; // Gold this.value = 10; } import me from "melong-js"; export default class ScoreLabel

return true; }

Once installed, run:

Don’t forget to preload the image in your src/js/resources.js :