Hello Everybody,
I’ve a new error, I can’t get fixed in my game CubeWorld
I fire an event after a button was pressed: {left or right arrow}
var Button = pc.createScript(‘button’);
Button.prototype.initialize = function() {
this.entity.element.on(‘click’, this.onClick, this);
};
Button.prototype.update = function(dt) { };Button.prototype.onClick = function (){
this.app.fire(this.entity.name, true);
};
this works fine, except a situation when the button is destroyed after the event has been catched… Now I get teh following error:
Error loading scripts. Open the browser console for details.
and in console:
Uncaught TypeError: Cannot read property ‘active’ of null
at ButtonComponent._fireIfActive (playcanvas-stable.dbg.js:46242)
at ButtonComponent._onClick (playcanvas-stable.dbg.js:46238)
at ElementComponent.fire (playcanvas-stable.dbg.js:741)
at ElementInput._fireEvent (playcanvas-stable.dbg.js:71542)
at ElementInput._onElementMouseEvent (playcanvas-stable.dbg.js:71428)
at ElementInput._handleUp (playcanvas-stable.dbg.js:71229)
what should i do?
It’s the first time ever, I used a ButtonElement…
thanx