Jump to content

destroy and parent.


clark
 Share

Recommended Posts

Hey!

I used to have a bunch of destroy methods on my objects which would essentially stop listening for signals etc.  I am a little sketchy with this.  But one day, I was having a nightmare with:
 

Phaser.Group.prototype.destroy = function (destroyChildren, soft) {    if (this.game === null) { return; }    if (typeof destroyChildren === 'undefined') { destroyChildren = true; }    if (typeof soft === 'undefined') { soft = false; }    this.removeAll(destroyChildren);    this.cursor = null;    if (!soft)    {        this.parent.removeChild(this);     <---- This, if parent is null?        this.game = null;        this.exists = false;    }};

So I ended up just deleting all my destroy() methods on the Game classes. When I updated today to the latest dev build. When I clear the world as part of entering my Game State, I get the same error, with the same problem:

this.game.state.start(GameStates.GAME, true, false);

I checked on the game state, and there is none of my own shutdown() or destroy() methods on that State so I am pretty sure it is unrelated to my previous issue.  I am finding it tough to get a stack trace. 

EDIT: This does not cause the error, but I am unaware of the byproducts of "not clearing" the world. 

that.game.state.start(SpotJS.GameStates.GAME, false, false);

Does anyone have an idea what is going wrong for me here? 

Thanks!

Link to comment
Share on other sites

  • 1 year later...

I was playing around with if I could use 'soft' to remove overlaps etc. But when I try the following I get the error: ReferenceError: soft is not defined

sprite.destroy(soft);

Is there a way to do this using destroy without killing the sprite? Maybe I'm not understanding 'soft' :(

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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