Example #1
0
        public Animation Clone()
        {
            var clone = new Animation();

            clone.LoopStartFrame = this.LoopStartFrame;
            clone.Frames = new AnimationFrame[this.Frames.Length];
            this.Frames.CopyTo(clone.Frames, 0);

            return clone;
        }
Example #2
0
        private void CreateTestAnimations()
        {
            const int frameHeight = 32;
            const int frameWidth = 32;
            const int frameDuration = 200;

            var walkDown = new Animation();
            walkDown.Frames = new Animation.AnimationFrame[]
                              {
                                  new Animation.AnimationFrame(0,0,frameHeight,frameWidth,frameDuration),
                                  new Animation.AnimationFrame(32,0,frameHeight,frameWidth,frameDuration),
                                  new Animation.AnimationFrame(64,0,frameHeight,frameWidth,frameDuration),
                                  new Animation.AnimationFrame(96,0,frameHeight,frameWidth,frameDuration),
                              };

            var walkUp = new Animation();
            walkUp.Frames = new Animation.AnimationFrame[]
                              {
                                  new Animation.AnimationFrame(0,32,frameHeight,frameWidth,frameDuration),
                                  new Animation.AnimationFrame(32,32,frameHeight,frameWidth,frameDuration),
                                  new Animation.AnimationFrame(64,32,frameHeight,frameWidth,frameDuration),
                                  new Animation.AnimationFrame(96,32,frameHeight,frameWidth,frameDuration),
                              };

            var walkRight = new Animation();
            walkRight.Frames = new Animation.AnimationFrame[]
                              {
                                  new Animation.AnimationFrame(0,64,frameHeight,frameWidth,frameDuration),
                                  new Animation.AnimationFrame(32,64,frameHeight,frameWidth,frameDuration),
                                  new Animation.AnimationFrame(64,64,frameHeight,frameWidth,frameDuration),
                                  new Animation.AnimationFrame(96,64,frameHeight,frameWidth,frameDuration),
                              };

            var walkLeft = new Animation();
            walkLeft.Frames = new Animation.AnimationFrame[]
                              {
                                  new Animation.AnimationFrame(0,96,frameHeight,frameWidth,frameDuration),
                                  new Animation.AnimationFrame(32,96,frameHeight,frameWidth,frameDuration),
                                  new Animation.AnimationFrame(64,96,frameHeight,frameWidth,frameDuration),
                                  new Animation.AnimationFrame(96,96,frameHeight,frameWidth,frameDuration),
                              };

            var idleDown = new Animation();
            idleDown.Frames = new Animation.AnimationFrame[]
                              {
                                  new Animation.AnimationFrame(0,0,frameHeight,frameWidth,0),
                              };

            var idleUp = new Animation();
            idleUp.Frames = new Animation.AnimationFrame[]
                              {
                                  new Animation.AnimationFrame(0,32,frameHeight,frameWidth,0),
                              };

            var idleRight = new Animation();
            idleRight.Frames = new Animation.AnimationFrame[]
                              {
                                  new Animation.AnimationFrame(96,64,frameHeight,frameWidth,0),
                              };

            var idleLeft = new Animation();
            idleLeft.Frames = new Animation.AnimationFrame[]
                              {
                                  new Animation.AnimationFrame(0,96,frameHeight,frameWidth,0),
                              };

            AnimationManager.AddAnimation(ANIMATION_KEY_MOVE_DOWN, walkDown);
            AnimationManager.AddAnimation(ANIMATION_KEY_MOVE_UP, walkUp);
            AnimationManager.AddAnimation(ANIMATION_KEY_MOVE_RIGHT, walkRight);
            AnimationManager.AddAnimation(ANIMATION_KEY_MOVE_LEFT, walkLeft);

            AnimationManager.AddAnimation(ANIMATION_KEY_IDLE_DOWN, idleDown);
            AnimationManager.AddAnimation(ANIMATION_KEY_IDLE_UP, idleUp);
            AnimationManager.AddAnimation(ANIMATION_KEY_IDLE_RIGHT, idleRight);
            AnimationManager.AddAnimation(ANIMATION_KEY_IDLE_LEFT, idleLeft);
        }