Jump to content

Getting strange warning when trying to extend from Sprite


Recommended Posts


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');

Sould work like this right? I searched for this but couldn't find anything similar. Anyone knows what the problem could be?


Edit: I found the mistake!

this.add.sprite(hunger); -> this.add.existing(hunger);

Sorry for the pointless Thread.


Edited by stray
Link to comment
Share on other sites


  • Recently Browsing   0 members

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