Is it need to remove event listener manually if the object is destroyed?

for example, if I call:

do I need to call

after the object is destroyed?

1 Like

As far as I know, if you add event listener with scene graph priority, then you do not need to call removeEventListener. If you add it with fixed priority, then you will need to remove the event listener manually.

3 Likes

When you add your object’s event listeners by addEventListenerWithSceneGraphPriority, you dont need to call the remove method

2 Likes

Hi, I’ve got the same issue and I was using “addEventListenerWithFixedPriority”. I fixed it manually removing the listener. I’ve been reading the API doc and there is no mention to that. May I ask where did you got this (very important) piece of information? I believe I missed to read some very important docs… Any help would be very much appreciated!
Thanks!

1 Like

duracellrabbid:
As far as I know, if you add event listener with scene graph priority, then you do not need to call removeEventListener. If you add it with fixed priority, then you will need to remove the event listener manually.

I also switched to addEventListenerWithFixedPriority for one of the Scenes, and if I do not remove listener:

_eventDispatcher->removeEventListener(touchListener);

then my App crashes on Windows but does not hang Android. If I add above code, then everything works fine.

Anyway, where is this difference between Fixed and SceneGraph listeners described?

1 Like