So let's say I have a class called CSprite which loads a sprite sheet. Within that class will be at least one CAnimation object which takes user-defined snippets from the sprite sheet and loops them.. so for example I might want:
CAnimation m_AnimNormal, m_AnimOnFire;
inside the actual CSprite object.

The problem is that I might have 20 or 30 such loops per sprite sheet. So I will need a vector (std::vector<CAnimation> anims) or something, but I don't want the programmer to just refer to them as "anims". I would like meaningful names, so that later I can just say something like:
instead of

But how do I go about creating useable names dynamically? The only thing I can think of is anims.push_back(whatever), which isn't very descriptive.

Of-course I could delve into strings and associate some string in a separate vector with each animation object and then set up a for loop to check the strings each time... but for some reason this seems like the wrong way to go about it...


9 Years
Discussion Span
Last Post by phalaris_trip

>But how do I go about creating useable names dynamically?
Use a map instead of a vector, then you can use a string to index the map instead of an integer, which makes things more meaningful:


So you mean something like std::map <const char*, CAnimation> anims; ?

Never used them before but yeah I guess that would do the trick.. thanks for quick reply,

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.