dussman Posted June 29, 2015 Share Posted June 29, 2015 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 More sharing options...
drhayes Posted June 30, 2015 Share Posted June 30, 2015 You still want that to be "Object.create(Phaser.Sprite.prototype);", otherwise you're getting a plain object back instead of something that points to the Sprite prototype. Link to comment Share on other sites More sharing options...
dussman Posted July 7, 2015 Author Share Posted July 7, 2015 You where absolutely right! thanks Link to comment Share on other sites More sharing options...
Recommended Posts