Original Post
Im trying to store a list of images for an object in a vector using the ZEngine 2d engine. I store the current frame (because of my inheritance method - GME_AObject derived from GME_Object) and i can't find the way to get a reference for the current frame using the iterator. it gives a compiler error, not a run-time: Relevant code: GME_Object.h any help would be much appreciated! oh yeah, also tried image = &(Frames.at(frame)); [edit: added source tags -SiCrane]
...
public:
virtual void update();
protected:
ZImage* image;
GME_AObject.h
public:
virtual void update();
protected:
vector<ZImage> Frames;
vector<ZImage>::iterator frame;
Uint32 frametime;
Uint32 timepassed;
GME_Object.cpp
void GME_Object::update()
{
x=x+(rEngine->GetFrameTime()*hspeed);
y=y-(rEngine->GetFrameTime()*vspeed);
}
GME_AObject.cpp
void GME_AObject::update()
{
this->GME_Object::update();
timepassed += (int)(rEngine->GetFrameTime()+0.5); //0.5 is to round up if nec
if (timepassed > frametime)
{
frame++;
if (frame != Frames.end())
image = *(Frames.at(frame)); <- COMPILER ERROR
{
frame = Frames.begin();
image = *(Frames.at(frame)); // <- COMPILER ERROR
}
timepassed = 0;
}
}