Skip to content

Commit

Permalink
awful animation bug fix
Browse files Browse the repository at this point in the history
Signed-off-by: MGZero <[email protected]>
  • Loading branch information
MGZero committed May 28, 2015
1 parent 0cc0099 commit c999758
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions King of Thieves/Graphics/CSprite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System.IO;

namespace King_of_Thieves.Graphics
{
Expand All @@ -24,6 +25,7 @@ public class CSprite : CRenderable
private bool _paused = false;
public bool removeFromDrawList = false;
private int _timeForCurrentFrame = 0;
private bool _animEnd = false;

private static Dictionary<int, double> _frameRateLookup = new Dictionary<int, double>();

Expand Down Expand Up @@ -99,9 +101,11 @@ public override bool draw(int x, int y, bool useOverlay = false)
frameY++;

if (frameY >= _imageAtlas.tileYCount)
{
frameY = 0;
_animEnd = true;
}
}

}
_size = _imageAtlas.getTile(frameX, frameY);
_position.X = x; _position.Y = y;
Expand All @@ -116,10 +120,9 @@ public override bool draw(int x, int y, bool useOverlay = false)
else if(_flipH)
CGraphics.spriteBatch.Draw(CTextures.rawTextures[CTextures.textures[_atlasName].source], _position, _size, overlay, _rotation, Vector2.Zero, 1.0f, SpriteEffects.FlipHorizontally, 0);
base.draw(x,y);
if (_framesPassed == _totalFrames - 1)
if (_animEnd)
{
_framesPassed = 0;
frameX = 0; frameY = 0;
_animEnd = false;
return true; //this is used to determine if the animation ended
}
return false;
Expand Down

0 comments on commit c999758

Please sign in to comment.