Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Difference between this.add.sprite() and game.add.sprite() in State


Raiper34
 Share

Recommended Posts

Absolutely nothing - both of them are references to the GameObjectFactory. The only real difference is that 'game.add.sprite' uses a global (window level) "game" object in order to add the sprite, where-as "this.add" uses a State level reference to the GameObjectFactory instead. You should nearly always use 'this.add', especially if packaging games up in wrappers or for native.

Link to comment
Share on other sites

  • 4 weeks later...

Hmm.. 

 

I'm trying to add some bitmap text to my extended sprite class like this: 

this.label = game.add.bitmapText(0, 0, 'font', 'some text, 16);

I then add 'this.label' as a child to the parent.

 

This works fine, but after reading this I became worried since I'm going to wrap it up later on.

 

Shouldn't I use 'game.add...' in this case? Using 'this' dont seem to work.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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