using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Content; namespace CarFire { class AnimateMelee { //member variables private AnimatedTexture SpriteTexture; string[] fileNames = new string[] { "graphics/meleeAttack", "graphics/meleeDying", "graphics/meleeExplosion", "graphics/meleeStanding", "graphics/meleeWalking" }; private ContentManager contentManager; //private GraphicsDeviceManager graphics; //private SpriteBatch spriteBatch; private string ph; private Vector2 position; private SpriteBatch character; //constructor(s) public AnimateMelee(ContentManager content) { SpriteTexture = new AnimatedTexture(Vector2.Zero, 0, 1.0f, 0.5f); contentManager = content; ph = fileNames[3]; position = Vector2.Zero; } //methods public void AttackLeft(SpriteBatch spriteBatch) { ph = fileNames[0]; //graphics = graphicsDeviceManager; //this.spriteBatch = spriteBatch; //spriteBatch. character = new SpriteBatch(spriteBatch.GraphicsDevice); Animate(); // SpriteTexture.Load(graphics.GraphicsDevice, contentManager, "fileNames[0]", 8, 12, true, 1); } public void Animate() { //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); //viewport = graphics.GraphicsDevice.Viewport; position = new Vector2(0, 0);//viewport.Width / 2, 0);//viewport.Height / 2f); character.Begin(); SpriteTexture.DrawFrame(character, position); character.End(); } } }