1
Graphics / Animation "flickering" when using float position.
« on: October 06, 2018, 05:58:46 pm »
Hi there, I'm doing a little project and I have a flickering problem.
You can clearly see the problem here (the while line on each side of the sprite) :
My movement code is very simple.
So my position is "always" a float.
If I cast my position to some int, everything is working fine.
But now, when I hit a wall, the sprite "shake".
And for information, I'm using a really simple spritesheet : https://opengameart.org/sites/default/files/OpenGunnerEnemySoldier_0.png where all sprite is 50*50 pixels.
I'm pretty sure there's a way to correct this flickering problem, but I can't figure it out...
Thank in advance guys!
You can clearly see the problem here (the while line on each side of the sprite) :
My movement code is very simple.
heroine.Position += this._Direction * time.AsSeconds() * 100;
So my position is "always" a float.
If I cast my position to some int, everything is working fine.
this._Heroine.Position = new Vector2f((int) this._Heroine.Position.X, (int)this._Heroine.Position.Y);
But now, when I hit a wall, the sprite "shake".
And for information, I'm using a really simple spritesheet : https://opengameart.org/sites/default/files/OpenGunnerEnemySoldier_0.png where all sprite is 50*50 pixels.
I'm pretty sure there's a way to correct this flickering problem, but I can't figure it out...
Thank in advance guys!