I want to add some trail effect to a moving object that will fade over time. This is what I've got so far:
game.Trail = me.Entity.extend({
init:function (x, y, settings)
{
this._super(me.Entity, 'init', [
x, y,
{
image: "ball",
width: 32,
height: 32
}
]);
(new me.Tween(this.renderable))
.to({
alpha : 0,
}, 5000)
.onComplete((function () {
me.game.world.removeChild(this);
}).bind(this))
.start();
},
update : function (dt) {
this.body.update(dt);
return (this._super(me.Entity, 'update', [dt]) || this.body.vel.x !== 0 || this.body.vel.y !== 0);
}
});
Demo (move with WASD or arrow keys)
Here is a link to the full project to test locally.
But I want to change the colors of the items in the trail in the same way the fading is done.
In phaser this could be done tinting the sprite, but I have no clue about how to achieve that on melonjs.
Note: if the effect can be done with basic shapes instead of images that will work too.