X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fcarfire;a=blobdiff_plain;f=CarFire%2FCarFire%2FCarFire%2FAnimateMelee.cs;h=bda8912f9bfe602fb7d6f2e28a28fd8dd75d1a73;hp=e114dbed0dbc30254ac2f636bec3724bab6d28a0;hb=692a2af57c7f1586b8513106acf47ddc0ac12748;hpb=e8ee0aa62a7e8b5dffa9e02c00c3e353a9e93b4c diff --git a/CarFire/CarFire/CarFire/AnimateMelee.cs b/CarFire/CarFire/CarFire/AnimateMelee.cs index e114dbe..bda8912 100644 --- a/CarFire/CarFire/CarFire/AnimateMelee.cs +++ b/CarFire/CarFire/CarFire/AnimateMelee.cs @@ -18,48 +18,62 @@ 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) + public AnimateMelee(ContentManager content, Player player) { SpriteTexture = new AnimatedTexture(Vector2.Zero, 0, 1.0f, 0.5f); contentManager = content; ph = fileNames[3]; position = Vector2.Zero; + Player = player; + changedGraphic = true; + } //methods - public void AttackLeft(SpriteBatch spriteBatch) + 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); - Animate(); + //character = new SpriteBatch(spriteBatch.GraphicsDevice); + character = spriteBatch; + Animate(drawSpot); // SpriteTexture.Load(graphics.GraphicsDevice, contentManager, "fileNames[0]", 8, 12, true, 1); } - public void Animate() + public void Animate(Vector2 drawSpot) { //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(0, 0);//viewport.Width / 2, 0);//viewport.Height / 2f); - - character.Begin(); - SpriteTexture.DrawFrame(character, position); - character.End(); + position = new Vector2(Player.Coordinates.X*Map.PixelsToUnitSquares, Player.Coordinates.Y*Map.PixelsToUnitSquares);//viewport.Width / 2, 0);//viewport.Height / 2f); + Console.WriteLine(drawSpot); + //character.Begin(); + SpriteTexture.DrawFrame(character, drawSpot); + //character.End(); } }