]> Dogcows Code - chaz/carfire/blobdiff - CarFire/CarFire/CarFire/AnimateMelee.cs
git-svn-id: https://bd85.net/svn/cs3505_group@167 92bb83a3-7c8f-8a45-bc97-515c4e399668
[chaz/carfire] / CarFire / CarFire / CarFire / AnimateMelee.cs
index 05220ee7c367c29254777ef3db364ce7d29f2faf..bda8912f9bfe602fb7d6f2e28a28fd8dd75d1a73 100644 (file)
@@ -18,12 +18,17 @@ namespace CarFire
         private ContentManager contentManager;\r
         //private GraphicsDeviceManager graphics;\r
         //private SpriteBatch spriteBatch;\r
-\r
+        private bool changedGraphic;\r
+        private string lastPh;\r
         private string ph;\r
         private Vector2 position;\r
         private SpriteBatch character;\r
         Player Player;\r
-\r
+        \r
+        public void Update(TimeSpan timeSpan)\r
+        {\r
+            SpriteTexture.UpdateFrame(timeSpan);\r
+        }\r
         //constructor(s)\r
         public AnimateMelee(ContentManager content, Player player)\r
         {\r
@@ -32,6 +37,7 @@ namespace CarFire
             ph = fileNames[3];\r
             position = Vector2.Zero;\r
             Player = player;\r
+            changedGraphic = true;\r
             \r
         }\r
 \r
@@ -40,9 +46,13 @@ namespace CarFire
         public void AttackLeft(SpriteBatch spriteBatch, Vector2 drawSpot)\r
         {\r
             ph = fileNames[0];\r
+            if (lastPh == ph)\r
+                changedGraphic = false;\r
+            else\r
+                changedGraphic = true;\r
+            lastPh = ph;\r
             //graphics = graphicsDeviceManager;\r
             //this.spriteBatch = spriteBatch;\r
-            //spriteBatch.\r
             //character = new SpriteBatch(spriteBatch.GraphicsDevice);\r
             character = spriteBatch;\r
             Animate(drawSpot);\r
@@ -56,7 +66,8 @@ namespace CarFire
             //character = new SpriteBatch(graphics.GraphicsDevice);\r
             // "character" is the name of the sprite asset in the project.\r
             Console.WriteLine(ph);\r
-            SpriteTexture.Load(character.GraphicsDevice, contentManager, ph, 8, 12, true, 1);\r
+            if(changedGraphic)\r
+                SpriteTexture.Load(character.GraphicsDevice, contentManager, ph, 8, 12, true, 1);\r
             //viewport = graphics.GraphicsDevice.Viewport;\r
             position = new Vector2(Player.Coordinates.X*Map.PixelsToUnitSquares, Player.Coordinates.Y*Map.PixelsToUnitSquares);//viewport.Width / 2, 0);//viewport.Height / 2f);\r
             Console.WriteLine(drawSpot);\r
This page took 0.019814 seconds and 4 git commands to generate.