Hi there…
I have a custom object(Pool) inherited from the Container.
I override the “add” method and after leaving the scene using this.start(…), if I go back to the scene again and want to use the “add” function, I see the following error:
phaser.min.js:1 Uncaught TypeError: Cannot read property 'remove' of null
at Pool.addHandler (phaser.min.js:1)
at Object.t.exports [as Add] (phaser.min.js:1)
at Pool.add (phaser.min.js:1)
at Pool.add (pool.js:31) <----**Problem is here**
at Match.poolDealFunc (match.js:874)
at Match.StartGame (match.js:473)
at Function.callback (match.js:239)
at initialize.update (phaser.min.js:1)
at initialize.h.emit (phaser.min.js:1)
at initialize.step (phaser.min.js:1)
The override section in Pool class is (Typically in the constructor):
this.origAdd = this.add;
this.add = function(child) {
this.lastInsertedChild = child;
child._index = this.list.length;
console.log('adding...',child);
this.origAdd(child); <----**Problem is here**
child.setOrigin(.5);
}
I do not delete the Pool object when I quit the current scene (I really could not do it!) .
So, when I re-enter the scene, I use the same previous object.
It seems that I have to do something about the overridden method! Maybe I’ll kill it or whatever! However, I do not know how to do these things!
Thanks