Exemplo n.º 1
0
        /// <summary>
        /// Loads a particular enemy sprite sheet and sounds.
        /// </summary>
        public void LoadContent(string spriteSet)
        {
            // Load animations.
            String tempSprite = spriteSet;
            spriteSet = "Sprites/" + spriteSet + "/";
            /*if (tempSprite.Equals("MonsterA") || tempSprite.Equals("MonsterB"))
            {
                gawkAnimation = new Animation(Level.Content.Load<Texture2D>(spriteSet + "Gawk"), 0.1f, true);
            }
            else if (tempSprite.Equals("MonsterC"))
                deathAnimation = new Animation(Level.Content.Load<Texture2D>(spriteSet + "Death"), 0.1f, false);*/

            runAnimation = new Animation(Level.Content.Load<Texture2D>(spriteSet + "Run"), 0.1f, true);
            idleAnimation = new Animation(Level.Content.Load<Texture2D>(spriteSet + "Idle"), 0.1f, true);
            runAnimation.setWindowWidth(64);
            idleAnimation.setWindowWidth(64);

            sprite.PlayAnimation(idleAnimation);

            // Calculate bounds within texture size.
            int width = (int)(idleAnimation.FrameWidth * 0.35);
            int left = (idleAnimation.FrameWidth - width) / 2;
            int height = (int)(idleAnimation.FrameWidth * 0.7);
            int top = idleAnimation.FrameHeight - height;
            localBounds = new Rectangle(left, top, width, height);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Loads the player sprite sheet and sounds.
        /// </summary>
        public void LoadContent()
        {
            // Load animated textures.
            idleAnimation = new Animation(Level.Content.Load<Texture2D>("Sprites/Player/Idle"), 0.1f, true);
            runAnimation = new Animation(Level.Content.Load<Texture2D>("Sprites/Player/Run"), 0.1f, true);
            jumpAnimation = new Animation(Level.Content.Load<Texture2D>("Sprites/Player/Jump"), 0.1f, false);
            dieAnimation = new Animation(Level.Content.Load<Texture2D>("Sprites/Player/Die"), 0.1f, false);
            crouchAnimation = new Animation(Level.Content.Load<Texture2D>("Sprites/Player/crouch"), 0.1f, false);
            attackAnimation = new Animation(Level.Content.Load<Texture2D>("Sprites/Player/Attack"), 0.1f, false);

            attackAnimation.setWindowWidth(128);
            crouchAnimation.setWindowWidth(64);
            idleAnimation.setWindowWidth(64);
            runAnimation.setWindowWidth(64);
            jumpAnimation.setWindowWidth(64);
            dieAnimation.setWindowWidth(128);
            dieAnimation.setFrameTime(0.75F);

            // Calculate bounds within texture size.
            int width = (int)(idleAnimation.FrameWidth * 0.4);
            int left = (idleAnimation.FrameWidth - width) / 2;
            int height = (int)(idleAnimation.FrameWidth * 0.8);
            int top = idleAnimation.FrameHeight - height;
            localBounds = new Rectangle(left, top, width, height);
        }