Jump to content

JS error after game.destroy


titmael
 Share

Recommended Posts

Hi,

 

when I use game.destroy() it nukes the game but not completely, I have some JS errors when I use a key I did bind on the game (spacebar, up, down ...) :

  1. Uncaught TypeError: Cannot read property 'disabled' of null (phaser.js:20317)

 

 

I'm using Phaser v2.0.2 "Ghealdan" - Built: Fri Mar 28 2014 01:30:50

 

Thank for your help

Link to comment
Share on other sites

I assume you are using signal binding like onDown?

I have set up a fiddle that sets up an onDown binding to do console logging when "1" is pressed. I'm getting (different) errors as well when I delete the game. I have even added quite a few lines to try and unbind the keys, but it doesn't seem to work. It might come down to the fact that "nuking" the game isn't really an ideal situation. Anyway, I think you are on to something.

 

http://jsfiddle.net/adamholdenyall/KP2GS/3/

Link to comment
Share on other sites

I think I see the problem. This is what the Phaser.Input.stop() method looks like:

    /**    * Stops the Keyboard event listeners from running (keydown and keyup). They are removed from the window.    *    * @method Phaser.Keyboard#stop    */    stop: function () {        this._onKeyDown = null;        this._onKeyUp = null;        window.removeEventListener('keydown', this._onKeyDown);        window.removeEventListener('keyup', this._onKeyUp);    },

I'll bet you that if those listeners get nulled out after they are removed instead of before then this method will work as intended.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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