I am re-working the sprite system in my Direct3D 3D engine and my XNA 2D tile engine. There are a few API-centric questions that I would like some input on.
The sprite system is composed of a sprite frame object, an animation object and a sprite object. A sprite frame is composed of normalized rectangle coordinates and texture ID information. A sprite animation is a collection of sprite frames. Each sprite then is a collection of sprite animation objects that are called animation tracks. Each track is assigned an integer ID so they can be played, stopped, etc.
My question is when adding an animation track to a sprite I have two options. I can allow the client to pass in the animation or I can have them pass in an animation name, grab the animation object from a collection in the engine and add it to the sprite.
Should the engine maintain the collection of animation objects or should I leave this up to the client? The less memory the engine manages the better in my book. I'm currently opting for letting the client worry about this since it does not feel like a responsibility the engine should have.
So in short:
bool Sprite::AddTrack(unsigned int trackID,Animation &animation)
bool Sprite::AddTrack(unsigned int trackID,const char *pAnimationName);
Often I find myself wanting to maintain this type of data in the engine but lately I've come to the realization that it might not be the engine's responsibility to do so. When the engine does not maintain this data and/or is not responsible for cleaning it up the engine code becomes much simpler and results in much fewer edge cases and cleanup related issues....at the expense of being a bit more unfriendly to the client.