Jump to content

How to addChild a sprite within a constructor?


dsb_mac
 Share

Recommended Posts

If you post your code, we could maybe see the issue.
 

I use constructors
 

var thing = function(game) {
    this.sprite = game.add.sprite(0, 0, 'thing');

   this.update = function() {
       this.sprite.x++;
   }
};

// in your main game area

function create() {
    this.thing = new thing(game);
}

function update() {
    this.thing.update();
}

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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