Following this example: https://phaser.io/examples/v2/sprites/extending-sprite-demo-1
I've been trying to extend MonsterBunny.
I've added this:
// here is an extension of a custom game object
SuperMonsterBunny = function (game, x, y, rotateSpeed, vertSpeed) {
MonsterBunny.call(this, game, x, y, rotateSpeed);
this.vertSpeed = vertSpeed;
this.ydir = 1;
};
SuperMonsterBunny.prototype = Object.create(MonsterBunny.prototype);
SuperMonsterBunny.prototype.constructor = SuperMonsterBunny;
SuperMonsterBunny.prototype.update = function() {
/*
this.y += this.vertSpeed * this.ydir;
if (this.y < 0 || this.y > h)
{
this.ydir *= -1;
}
*/
};
This works fine, and the commented out code works as expected. (when it's uncommented!)
The extended class's update overrides the parent class, which is expected, but, I can't find a way of calling super.update() or equivalent.
Can anyone enlighten me?