예제 #1
0
        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);
        }
예제 #2
0
        // 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);
        }
예제 #3
0
        // 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);
        }
예제 #4
0
        // 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);
        }
예제 #5
0
 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;
 }