C ++ Can't increment variable
I am working on an animation class for a small game engine and for some reason the frame counter doesn't want to increase, it stays at 0 or 1.
This is the Animation :: Step code (where increment is assumed here):
void Animation::Step()
{
...
time += (float)glfwGetTime();
if (time >= Speed)
{
time = 0;
if (f++ >= count - 1)
{
...
}
}
// Here I do some math to get a clip rectangle...
...
}
Now this is the part where the :: Step animation is called:
inline void DrawAnimation(Animation ani, Vec2 pos, BlendMode mode, DrawTextureAttributes attr)
{
ani.Step();
...
// draw texture
}
And in the mainloop game:
void on_render(Renderer r)
{
DrawTextureAttributes attr;
attr.Scale = Vec2(1.5);
r.DrawAnimation(ani, Vec2(320, 240), BlendMode::Normal, attr);
}
EDIT: Class definition:
class Animation
{
public:
Animation() {}
Animation(Texture2D tex, int rows, int cols, int *frames, float speed, bool loop=false);
Animation(Texture2D tex, int rows, int cols, float speed, bool loop=false);
Texture2D Texture;
std::vector<int> Frames;
float Speed;
bool Loop;
float getCellWidth();
float getCellHeight();
void Step();
UVQuad RETUV;
private:
int f, r, c; // here F
float w, h;
float time;
};
Ok, thanks in advance! (and sorry for my curious bad english)
+3
source to share
1 answer