コード例 #1
0
        public void PlayAnimation(Animation animation)
        {
            if (Animation == animation)
            {
                return;
            }

            this.animation = animation;
            this.frameIndex = 0;
            this.time = 0.0f;
        }
コード例 #2
0
        public void LoadContent()
        {
            player = content.Load<Texture2D>("HeroSprite/hero");

            idleAnimation = new Animation(player, 0.1f, true, 16);

            int positionX = (Level.windowWidth / 2) - (player.Width / 4);
            int positionY = (Level.windowHeight / 2) - (player.Height / 4);
            playerPosition = new Vector2((float)positionX, (float)positionY);

            spritePlayer.PlayAnimation(idleAnimation);
        }
コード例 #3
0
        public void Update(GameTime gameTime)
        {
            if (level.mouseState.LeftButton == ButtonState.Pressed && level.oldMouseState.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Released)
            {
                player = content.Load<Texture2D>("HeroSprite/hero22");

                idleAnimation = new Animation(player, 0.1f, false, 15);

                int positionX = (Level.windowWidth / 2) - (player.Width / 4);
                int positionY = (Level.windowHeight / 2) - (player.Height / 4);
                playerPosition = new Vector2((float)positionX, (float)positionY);

                spritePlayer.PlayAnimation(idleAnimation);
            }
        }