Jump to content

Object delegation fail


Recommended Posts

Hi everybody,


I'm pretty noob to Phaser and I'm trying to make a prefab through object delegation. If i'm not mistaken, the tutorial way to create a prefab is like this:

var Fighter = function (game, x, y, image) {    Phaser.Sprite.call(this, game, x, y, image);};Fighter.prototype = Object.create(Phaser.Sprite.prototype);Fighter.prototype.constructor = Fighter;

And I'm trying to do it like this:

var Fighter = function ( game, x, y, image ) {    var fighter = Object.create(Phaser.Sprite);    Phaser.Sprite.call( fighter, game, x, y, image );    return fighter;};

But it gives me the following error:

Uncaught TypeError: this.onTextureUpdate is not a function 

Any ideas about what the problem can be? 

thanks in advance


Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...