public List <AnimationFrame> ParseAnimationScript(string animationScript) { List <AnimationFrame> animation = new List <AnimationFrame>(); string[] cmdList = animationScript.Split(";".ToCharArray()); foreach (string cmd in cmdList) { string[] argList = cmd.Split(",".ToCharArray()); if (argList.Length == 2) { AnimationFrame frame = new AnimationFrame(); frame.spriteColumn = int.Parse(argList[0], System.Globalization.CultureInfo.InvariantCulture); frame.length = float.Parse(argList[1], System.Globalization.CultureInfo.InvariantCulture); animation.Add(frame); } } return(animation); }
// Constructor for SpriteModel. Loads up the texture referenced by spriteSheetPath to use for drawing. // Each individual sprite should be fit to a 24×32 box with the bottom center of the box corresponding to // the SpriteModel's origin. A sprite sheet is expected to have a column of four sprites for every frame // designated by numFrames. A sprite sheet should be 128 pixels tall and padded on the right to bring the // total texture width to a power of two. public SpriteModel(Game gameInstance, int numFrames) { this.gameInstance = gameInstance; this.graphicsDevice = gameInstance.GraphicsDevice; this.effect = gameInstance.Content.Load <Effect>("effect_spritemodel"); this.nameFont = gameInstance.Content.Load <SpriteFont>("font_04b08"); this.numColumns = numFrames; AnimationFrame dummyFrame = new AnimationFrame(); dummyFrame.length = 1; dummyFrame.spriteColumn = 1; passiveAnimation = new List <AnimationFrame>(); passiveAnimation.Add(dummyFrame); activeAnimation = new List <AnimationFrame>(); activeAnimation.Add(dummyFrame); }
// Constructor for SpriteModel. Loads up the texture referenced by spriteSheetPath to use for drawing. // Each individual sprite should be fit to a 24×32 box with the bottom center of the box corresponding to // the SpriteModel's origin. A sprite sheet is expected to have a column of four sprites for every frame // designated by numFrames. A sprite sheet should be 128 pixels tall and padded on the right to bring the // total texture width to a power of two. public SpriteModel(Game gameInstance, int numFrames) { this.gameInstance = gameInstance; this.graphicsDevice = gameInstance.GraphicsDevice; this.effect = gameInstance.Content.Load <Effect>("effect_spritemodel"); this.nameFont = gameInstance.Content.Load <SpriteFont>("font_04b08"); this.numColumns = numFrames; AnimationFrame dummyFrame = new AnimationFrame(); dummyFrame.length = 1; dummyFrame.spriteColumn = 1; passiveAnimation = new List <AnimationFrame>(); passiveAnimation.Add(dummyFrame); activeAnimation = new List <AnimationFrame>(); activeAnimation.Add(dummyFrame); //vertexDeclaration = new VertexDeclaration(graphicsDevice, VertexPositionTexture.VertexElements); spriteBatch = new SpriteBatch(graphicsDevice); }
// Constructor for SpriteModel. Loads up the texture referenced by spriteSheetPath to use for drawing. // Each individual sprite should be fit to a 24×32 box with the bottom center of the box corresponding to // the SpriteModel's origin. A sprite sheet is expected to have a column of four sprites for every frame // designated by numFrames. A sprite sheet should be 128 pixels tall and padded on the right to bring the // total texture width to a power of two. public SpriteModel(Game gameInstance, int numFrames) { this.gameInstance = gameInstance; this.graphicsDevice = gameInstance.GraphicsDevice; this.effect = gameInstance.Content.Load<Effect>("effect_spritemodel"); this.nameFont = gameInstance.Content.Load<SpriteFont>("font_04b08"); this.numColumns = numFrames; AnimationFrame dummyFrame = new AnimationFrame(); dummyFrame.length = 1; dummyFrame.spriteColumn = 1; passiveAnimation = new List<AnimationFrame>(); passiveAnimation.Add(dummyFrame); activeAnimation = new List<AnimationFrame>(); activeAnimation.Add(dummyFrame); vertexDeclaration = new VertexDeclaration(graphicsDevice, VertexPositionTexture.VertexElements); }
public List<AnimationFrame> ParseAnimationScript(string animationScript) { List<AnimationFrame> animation = new List<AnimationFrame>(); string[] cmdList = animationScript.Split(";".ToCharArray()); foreach (string cmd in cmdList) { string[] argList = cmd.Split(",".ToCharArray()); if (argList.Length == 2) { AnimationFrame frame = new AnimationFrame(); frame.spriteColumn = int.Parse(argList[0], System.Globalization.CultureInfo.InvariantCulture); frame.length = float.Parse(argList[1], System.Globalization.CultureInfo.InvariantCulture); animation.Add(frame); } } return animation; }