Class inheriting from CCNode not calling it's destructor when removed with cleanup is called.

What could be causing this? I have a GameObject class that derives from classes that eventually derive from CCNode.

This game object gets deleted when far enough from the player by calling myObject->removeFromParentWithCleanup(true);

The object visually disappears but the destructor is not called until the scene is exited.

The class does not use touchDelegate or anything like that. It only uses scheduleUpdate and has children that also has scheduleUpdate.

Any ideas on why this could be happening?

extra info

  • The GameObject class has a sprite as child that is running an animation.

Figured it out.

I had a CCArray of GameObjects on my scene. I had to remove them from this array before removing from the parent.
I guess the objects don’t delete if there is a reference to the object still existing somewhere.