X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fcarfire;a=blobdiff_plain;f=CarFire%2FCarFire%2FCarFire%2FAnimateMelee.cs;fp=CarFire%2FCarFire%2FCarFire%2FAnimateMelee.cs;h=bda8912f9bfe602fb7d6f2e28a28fd8dd75d1a73;hp=05220ee7c367c29254777ef3db364ce7d29f2faf;hb=692a2af57c7f1586b8513106acf47ddc0ac12748;hpb=253f769f5330fda55c2dfca8aa5e27987c3de98e diff --git a/CarFire/CarFire/CarFire/AnimateMelee.cs b/CarFire/CarFire/CarFire/AnimateMelee.cs index 05220ee..bda8912 100644 --- a/CarFire/CarFire/CarFire/AnimateMelee.cs +++ b/CarFire/CarFire/CarFire/AnimateMelee.cs @@ -18,12 +18,17 @@ namespace CarFire private ContentManager contentManager; //private GraphicsDeviceManager graphics; //private SpriteBatch spriteBatch; - + private bool changedGraphic; + private string lastPh; private string ph; private Vector2 position; private SpriteBatch character; Player Player; - + + public void Update(TimeSpan timeSpan) + { + SpriteTexture.UpdateFrame(timeSpan); + } //constructor(s) public AnimateMelee(ContentManager content, Player player) { @@ -32,6 +37,7 @@ namespace CarFire ph = fileNames[3]; position = Vector2.Zero; Player = player; + changedGraphic = true; } @@ -40,9 +46,13 @@ namespace CarFire public void AttackLeft(SpriteBatch spriteBatch, Vector2 drawSpot) { ph = fileNames[0]; + if (lastPh == ph) + changedGraphic = false; + else + changedGraphic = true; + lastPh = ph; //graphics = graphicsDeviceManager; //this.spriteBatch = spriteBatch; - //spriteBatch. //character = new SpriteBatch(spriteBatch.GraphicsDevice); character = spriteBatch; Animate(drawSpot); @@ -56,7 +66,8 @@ namespace CarFire //character = new SpriteBatch(graphics.GraphicsDevice); // "character" is the name of the sprite asset in the project. Console.WriteLine(ph); - SpriteTexture.Load(character.GraphicsDevice, contentManager, ph, 8, 12, true, 1); + if(changedGraphic) + SpriteTexture.Load(character.GraphicsDevice, contentManager, ph, 8, 12, true, 1); //viewport = graphics.GraphicsDevice.Viewport; position = new Vector2(Player.Coordinates.X*Map.PixelsToUnitSquares, Player.Coordinates.Y*Map.PixelsToUnitSquares);//viewport.Width / 2, 0);//viewport.Height / 2f); Console.WriteLine(drawSpot);