Jump to content

[Novice advice] How to create a group outside of the Game prototype?


Recommended Posts

Hi I am a beginner to javascript and to the Phaser framework and so far I am loving it!

However I've gotten to a problem that I have been trying to fix for days with no luck... I could sure use some help :)


I am trying to convert my phaser game into phaser states following the basic template in the phaser examples file.

The problem I have is that I cant seem to add a group outside of the game prototype.

My game prototype:

"BasicGame.Game.prototype = { ...};"

and my game constructor:

"BasicGame.Game = function (game) {...};


seem to work fine in that the game runs without error except when I try to add a group with this.add.group();

I must add the group outside of the game prototype because else I will not be able to add sprites to it using functions not

contained in the prototype!


I have tried all solutions I could think of or search, does anyone have any suggestions?

Link to comment
Share on other sites

we really need a little more information in order to help. what are you trying to accomplish? when you say "this.add.group()" what object is this call made from (i.e. what object is "this" referring to)? where do you want to call addGroup() from exactly?

I just wrote you a giant description of what the problem was.

In writing the description I solved the problem.

I love you. Thanks :)

Link to comment
Share on other sites


  • Recently Browsing   0 members

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