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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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