Refresh your browser. You should see an orange square that moves left and right with the arrow keys. Create src/js/entities/Collectible.js :
constructor(x, y) { super(x, y, { width: 32, height: 32 }); // Load sprite this.renderable = new me.Sprite(0, 0, { image: me.loader.getImage("player_sprite") }); this.renderable.addAnimation("idle", [0]); this.renderable.addAnimation("walk", [0, 1, 2, 1], 100); this.renderable.setCurrentAnimation("idle"); } melonjs tutorial
Now register this entity in your main scene ( src/js/scenes/PlayScene.js ): Refresh your browser
this.body.update(dt); this.pos.x += this.body.vel.x; this.pos.y += this.body.vel.y; y) { super(x
addPoints(points) { this.score += points; }