Hi! I’m currently working on a simple project, and as part of it, I needed to register player input.
So I added event listener, so whenever player presses inside parent node, other stuff happens.
onLoad() {
this.node.parent.on(cc.Node.EventType.TOUCH_START, function (event) {
this.Pressed = true;
console.log("Pressed");
}, this);
this.node.parent.on(cc.Node.EventType.TOUCH_END, function (event) {
this.Pressed = false;
console.log("Lifted");
}, this);
}
And then way dowm the code I tried removing those, but it doesn’t seem to work
...
this.node.parent.off(cc.Node.EventType.TOUCH_START, function (event) {
this.Pressed = true;
console.log("Pressed");
}, this);
this.node.parent.off(cc.Node.EventType.TOUCH_END, function (event) {
this.Pressed = false;
console.log("Lifted");
}, this);
...
Code certainly does reach those commands, as other methods there seem to work, but nor .off(), nor even .destroy() called on this.node don’t remove the listeners.
Really need help with that as there should be many objects with that script and I really don’t want to pile up event listeners.
Also, probably important, I use cocos 2.4.10 + TS and don’t intend to switch version of this project