This is giving me quite some trouble and extra code write.
Just wondering, can I set a function that will be called upon my object deletion ti free my object user data?
Not sure if the question is clear, but I wanted to use this:
orxObject_SetUserData(newMonster, newMonsterInfo);
with:
orxObject_SetLifeTime(monster, 2.0);
But my user data needs to be freed (actually given back to a memory bank).
Thanks in advance.
Comments
I'm assuming you're not using Scroll as the UserData attachment would be used by Scroll and not available for your own needs.
You also wouldn't have this problem as your own ScrollObject derivates would have their OnDelete() method being called before destruction.
With orx, the way to do this is by listening to the orxEVENT_TYPE_OBJECT events. Then, in your event handler, the ID you're interested in is orxOBJECT_EVENT_DELETE.
Example:
Would it be possible to add this feature (a free function for the user data in the orxOBJECT struct) in the object in the future? It seems to me that this would be a much simpler and better way to handle it.