0 Favourites

Flickering on animation

This forum is currently in read-only mode.
  • Hi all,

    I have an invisible box with the platform behaviour and an sprite attached to it which does all the character animation. At first I let the sprite do a looping running animation and the box do the movement. But this looked a bit fake because the character was sliding on the floor, so I figured I want to move the character just a different amount based on his animation frame.

    So my solution is an onAnimationFrameChange event in which I add a value to the X-position based on the current animation frame which looks very convincing.

    But: the animation does a kind of flickering like there are two animation frames overlapping for a very short time or not showing at all. This only occurs when the project fps settings are set to vSynched. When I put it to unlimited eveything seems fine which leads me to the conclusion that somehow the new sprite is drawn in the moment when the screen is updating or something like that.

    Is it possible to use a kind of buffer, where everything is drawn and only after that is shown?

    Or what could cause this flickering?

    Thank you for any advice on this!

  • It's impossible for the display to change while the screen is being drawn if V-Sync is enabled - it's designed specifically to prevent that. My best guess is your events are switching between animation frames every tick. Post a .cap.

  • Thanks for the info! Hm I guess I messed up a little...

    Here is my cap. I want to mention the sprites are not free, I just use them for testing, the cap is not ment to be a game someday, just a playground to learn construct better.


  • Or perhaps someone known another way of doing what I want to achieve: moving the player only with every animation step. Is there another possibility for that?

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • If your animation appears to be sliding, then you just need to adjust the values between movement speed and animation speed so that they match up. Either slow down or speed up you object, or lengthen/shorten your animation frames.

    Look at how many pixels your character's foot moves in a single loop, and make sure that your character moves roughly the same amount in the same timeframe. The simplest way to do this is through trial and error - test different values until you find one that works. To save compilation time, you could tie the movement speed to some keys and adjust it on the fly, then input your final values after testing.

    Of course, if your character has acceleration and deceleration, there will always be a point when the feet don't match the motion. In game maker I would fix this by tying the animation speed to the movement speed, but I'm not sure if that's possible in Construct. You could fake it by having two animations - run and walk - and switch between them when you hit a certain speed.

  • Thanks, good idea with a walking and a running animation. I guess with the running animation it is not so crucial that the player slides 1 or 2 pixels.

    But imagine the following scenario: I have a climbing animation. The player is hanging on a platform and is climbing up. The first animation frame is the hanging, his hands high over his head are positioned tight on the platforms edge. Now the next frame the player pulls himself up, his hands are then in front of his face, still tied to the exact same edge. Since the second animation frame has lesser hight, I have to put the player sprite lets say 20 pixels higher to match the hands with the edge. Lets say during the first and the second animation frame are 20 ticks/event-loops. Then I would have to move my player 1 pixel every tick so that it lines up the edge when the animation changes to frame 2. But during the whole time that animation frame 1 is on the player flies magically up from the edge which is not right.

    Hm...have I explained the problem well enough?

  • Sounds like a problem with the animations hotspot...

    Make sure that the hotspot is in a good place for the animation. For a climbing/pulling up animation I suggest putting the hotspot for each frame on the players hands. This way, the point at which they are attached to the ledge will remain consistent and will avoid you having to make weird pixel buffers (empty space) on your animation frames to make it look right.


  • Thanks, I tried pinning the hotspot to the hand but this only changes the values I have to add at each frame. This does not stop the sprite from sliding during to frames

    I don't understand what you mean by pixel buffers and empty space, maybe I described it wrong, there are no blank frames in the animation, I only want to pause the movement of the sprite until the next animation frame comes into play.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)