Flickering on animation

For questions about using Classic.

Post » Wed Mar 24, 2010 2:29 pm

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!
B
2
G
2
Posts: 22
Reputation: 694

Post » Wed Mar 24, 2010 4:51 pm

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.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,478

Post » Thu Mar 25, 2010 12:07 pm

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.
http://www.box.net/shared/0ec58fo15r
B
2
G
2
Posts: 22
Reputation: 694

Post » Fri Mar 26, 2010 7:53 am

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?
B
2
G
2
Posts: 22
Reputation: 694

Post » Fri Mar 26, 2010 10:03 am

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.
B
2
S
2
G
3
Posts: 105
Reputation: 1,510

Post » Fri Mar 26, 2010 1:07 pm

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?
B
2
G
2
Posts: 22
Reputation: 694

Post » Fri Mar 26, 2010 6:31 pm

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.

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
45
S
17
G
37
Posts: 2,853
Reputation: 25,966

Post » Sat Mar 27, 2010 6:42 pm

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.
B
2
G
2
Posts: 22
Reputation: 694


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest