Пример #1
0
        /// <summary>
        /// Clones an animation
        /// </summary>
        /// <returns>the cloned animation</returns>
        public override object Clone()
        {
            var animationClone = new PlayerAnimation(Frames);

            animationClone.FrameWidth = FrameWidth;
            animationClone.FrameHeight = FrameHeight;
            animationClone.Reset();

            return animationClone;
        }
Пример #2
0
        /// <summary>
        /// Loads all content used by the player
        /// </summary>
        protected override void LoadContent()
        {
            // Hero
            var spriteSheet = Game.Content.Load<Texture2D>(@"BoyHeroWalk");
            var animations = new Dictionary<AnimationKey, PlayerAnimation>();

            var animation = new PlayerAnimation(new[]
                {
                    new Rectangle(0, 0, 16, 32),
                    new Rectangle(16, 0, 16, 32),
                    new Rectangle(32, 0, 16, 32)
                });
            animations.Add(AnimationKey.Down, animation);

            animation = new PlayerAnimation(new[]
                {
                    new Rectangle(0, 32, 16, 32),
                    new Rectangle(16, 32, 16, 32),
                    new Rectangle(32, 32, 16, 32)
                });
            animations.Add(AnimationKey.Up, animation);

            animation = new PlayerAnimation(new[]
                {
                    new Rectangle(0, 64, 16, 32),
                    new Rectangle(16, 64, 16, 32),
                    new Rectangle(32, 64, 16, 32)
                });
            animations.Add(AnimationKey.Left, animation);

            animation = new PlayerAnimation(new[]
                {
                    new Rectangle(0, 96, 16, 32),
                    new Rectangle(16, 96, 16, 32),
                    new Rectangle(32, 96, 16, 32)
                });
            animations.Add(AnimationKey.Right, animation);

            Sprite = new PlayerAnimatedSprite(spriteSheet, animations) {Position = new Vector2(96, 96)};

            TextPanel = new TextPanel(Game, 0, 0, true) {Visible = false};
            Components.Add(TextPanel);

            _pauseScreen = new Pause(Game, 0, 0);
            Components.Add(_pauseScreen);

            base.LoadContent();
        }