Jump to content

Extending group


erasmosoares
 Share

Recommended Posts

How to create a class extending group? My intention is to create a popup class that extends group. The idea is to put all sprites, buttons to the group so that I can handle it.

 

I've done something like that but it doesn't work.

 

Popup = function(game, parent, name, useStage){};
 
Popup.prototype = Object.create( Phaser.Group.prototype);
Popup.prototype.constructor = Popup;
Link to comment
Share on other sites

The way you did it should work if you add the phaser group consuctor call in your constructor:

 

function Popup(game, parent, name, useStage) {

    Phaser.Group.call(this, game, parent, name, useStage);

};

 

Popup.prototype = Object.create( Phaser.Group.prototype);
Popup.prototype.constructor = Popup;
 
or you can do it this way but it won't work if there is typeof check:

 

function Popup(game, parent, name, useStage) {

    Phaser.Group.call(this, game, parent, name, useStage);

};

 

Popup.prototype = Phaser.Utils.extend(true, Popup.prototype, Phaser.Group.prototype);

Popup.prototype.constructor = Popup

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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