Jump to content

Extended Group throws error on destroy()


xnamex
 Share

Recommended Posts

Hi everyone,

 

I'm extending the Phaser.Group Class, so I could have a 'views' manager, to handle the game states and being able to easily add/remove views as I go.

 

I have some problems when removing the views(groups) from the game.

Here's my GameView code:

function GameView(game) {	Phaser.Group.call(this, game);	//calling init methods and other stuff - simple stuff}GameView.prototype = Object.create(Phaser.Group.prototype);GameView.prototype.constructor = GameView;

..and here how I instantiate it, inside the create method:

var view = new GameView(game);//and destroy itview.destroy();

..and I get an error on mouse move: Uncaught TypeError: Cannot read property 'visible' of null

 

 

So what am I doing wrong?

 

Thanks,

Link to comment
Share on other sites

Well after several hours of digging I found this chunk of code, on the dev branch (https://github.com/photonstorm/phaser/blob/dev/examples/wip/group%20destroy.js) which I hope would fix the issue:

//The optional parameter here will destroy the Sprites as well as the Group.//The default is 'false' which means destroy the Group, but none of the children.group.destroy(true);

So, until 1.1.4, idk, I'll have to wait and see.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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