agmcleod Posted March 11, 2014 Share Posted March 11, 2014 I seem to be getting an error which I believe is related to the event handling. Inside an onInputDown, I call destroy on the said sprite to remove it from the game. However I instantly get the error: TypeError: this.sprite is null phaser.min.js:6 Running on chrome, I see: Uncaught TypeError: Cannot read property 'events' of null Not sure why I'm getting separate errors, but it seems to be related to events. Is there a proper way to cleanup events? Link to comment Share on other sites More sharing options...
rich Posted March 11, 2014 Share Posted March 11, 2014 Could you try this in 1.2 please? As I spent quite a while tidying up when and how things were destroyed in callbacks that should have sorted out things like this. Link to comment Share on other sites More sharing options...
agmcleod Posted March 11, 2014 Author Share Posted March 11, 2014 After updating my bitmapfont objects, since it used the old API, it seems to work. Though I wonder if you have a suggestion for a better way to handle the following. This is my click handler on the sprite:function() { this.showDialogue = true; keepsake.DialogueManager.show(); this.item.destroy(); this.item = null; this.dialogues[0].stageBitmapText(); }A Layer object is what's passed as "this", and it contians the said sprite, in this.item. I call destroy, but then in my function where i swap layers:Layer.prototype.hide = function() { this.music.stop(); if(this.item) { this.item.kill(); } this.background.kill(); keepsake.DialogueManager.hide();}The this.item still validates, and it tries to kill the sprite, which fails due to me calling destroy on it earlier. So for now I set it to null in the first statement, but I'm wondering if there's a better way to handle its cleanup. Link to comment Share on other sites More sharing options...
Recommended Posts