The following is an abridged version of my Sprite class:
class Sprite
{
struct SpriteState {
Vector3 position;
int width, height;
double rotation, scaling;
};
std::map<int, SpriteState> stateVector;
}
I'd like to create a SpriteState object through a member function that looks something along the lines of the following:
SpriteState newSpriteState(
Vector3 position = stateVector.rbegin()->second.position,
int width = = stateVector.rbegin()->second.width,
int height = = stateVector.rbegin()->second.height,
double rotation = stateVector.rbegin()->second.rotation,
double scaling = stateVector.rbegin()->second.scaling)
{ SpriteState a; a.position = position; a.width = width; a.height = height; a.rotation = rotation; a.scaling = scaling; return a; }
I get the following error:
a nonstatic member reference must be relative to a specific object
The basic idea behind the class itself is to store the various states of the sprite as it changes so that I can easily recover to a previous state if needed.
However, in most cases the Sprite is only updated with new position values while width, height, rotation, and scaling stays pretty much the same - which means I only change the position value while popping up and saving again references from the last state saved for the other values.
I'd hence like to be able to set default values for the function so that I don't have to laboriously write the same values repeatedly.
Any possible ideas on implementation?
= =stateVector.rbegin()->second.width ?