Jump to content
  • Advertisement
Sign in to follow this  
The Lion King

Animation Flickering

This topic is 5109 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am using DirectX9 Sprite functions to animate my sprites. There is a slight flickering with the animation of the sprite. I am animating them ... I mean moving them with a simple method i.e. if PositionX is the position of Sprite on X - Axis, then PositionX =+ 10.0f; But I can notice a very slight flickering during the animation. Here is the code that I use for drawing and setting position of the sprite: D3DXVECTOR2 Center (1.0f, 1.0f); // Center of Sprite D3DXVECTOR2 Scale (ScaleX, ScaleY); // Scale alue for Sprite D3DXVECTOR2 Translate (PosX, PosY); // Translation for Sprite D3DXVECTOR2 RotationCenter (RotXCenter, RotYCenter); // Rotation Center for Sprite D3DXMATRIX Matrix; // 2D Matrix // Transform Sprite D3DXMatrixTransformation2D (&Matrix, &Center, NULL, &Scale, &RotationCenter, D3DXToRadian (Rotation), &Translate); Object->SetTransform (&Matrix); // Set Transformation Object->Begin (D3DXSPRITE_ALPHABLEND); // Begin drawing Sprite // Draw Sprite Object->Draw (Texture->Object, NULL, NULL, NULL, ColorVal); Object->End (); // End drawing Sprite Is there something I am missing or something that I need to know and I do not know. Any hints or helps will be highly appreciated :)

Share this post

Link to post
Share on other sites
The flickering might also be optical. You are moving the sprite in steps of 10 pixels. Because of that there object moves pretty fast, and thus might flicker.

You should look up time based movement for smooth animation. The idea is simple:

Start = GetHighPerformaceCounter();
Start Frame
Update all objects
Render all objects
End Frame
End = GetHighPerformaceCounter();

With Start and End you can calculate how long the frame took to execute. Next time you update all the objects, you simply do this:
Object.X = SpeedX * FrameTime;(FrameTime should be a float or double);
Object.Y = SpeedY * FrameTime;

If you update all your objects like that, the movement is perfectly smooth, unless the framerate drops below the 30.


Share this post

Link to post
Share on other sites
Thanks for the reply guys.

But I think DX9 handles Double Buffering automatically.

And with the animation with the FPS ... flickering effect is still in there.

It seems that the faster I move ... I mean the greater distance I cover, greater is the flickering effect.

Any other advice? :(

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!