Flickering frames...

Hey me again, I have this problem with my animations: there is like a flickering if the animation frame for moving left/right is greater than the max frames for when it is idle, let me explain:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
if(movingLeft) 
{
activeFrameColumn = 1;
entityAnim->m_maxFrames = 8;
}
if(movingRight) 
{
activeFrameColumn = 2;
entityAnim->m_maxFrames = 8;
}
else
{
activeFrameColumn = 0;
entityAnim->m_maxFrames = 4;
}


As you can see the max frames change to half when idle, the problem is if you are moving and the current frame is > 4 if you stop moving then you will see like a "blank" frame (flickering) although it is really fast, it is kind of annoying... any ideas on how to solve it?
It's hard to say because you leave out a lot of information.

I guess you have the frames for each animation in it's own column so that is what activeFrameColumn is for. Somewhere you must have a variable that determines the current frame in the animation. Can't you just set that variable to 0 when you change animation?

EDIT: shouldn't it be else if on line 6?
Last edited on
Put this after that above code:

1
2
if(entityAnim->m_currentFrame >= entityAnim->m_maxFrames)
   entityAnim->m_currentFrame = 0;
@peter87: yes it is an else if that is how I have it, I didn't copy and paste, that is why is not there, I forgot to put it there.

@Disch: lol you are embarrassing me man, again such a simple solution and I completely overlooked it, thanks man.

this is how I had and it wasn't working:
if (m_activeFrame >= m_maxFrames ) { m_activeFrame = 0;}

but this was in the Canimation::animate() function, that is why it wasn't working, I needed a check in the entity::animation() function... thanks again.
Last edited on
Topic archived. No new replies allowed.