Jump to content

Extended Group throws error on destroy()


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?



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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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