stray Posted September 5, 2017 Share Posted September 5, 2017 (edited) Hello, I am new to Phaser and I am having problems subclassing Phaser.Sprite. I get the warning 'The `x` argument value ([object Object]) should be a number. phaser.js:44979:13' and the Sprite does not appear. Here is my code for the Object: var Status = (function(){ function Status(game, x, y, img) { Phaser.Sprite.call(this, game, x, y, img); } Status.prototype = Object.create(Phaser.Sprite.prototype); Status.prototype.constructor = Status; return Status; })(); And Here is how I create a new instance of it (in the create function of a state): var hunger = new Status(game,0,0,'hunger'); this.add.sprite(hunger); Sould work like this right? I searched for this but couldn't find anything similar. Anyone knows what the problem could be? Thanks! Edit: I found the mistake! this.add.sprite(hunger); -> this.add.existing(hunger); Sorry for the pointless Thread. Edited September 5, 2017 by stray Link to comment Share on other sites More sharing options...
Recommended Posts