Пример #1
0
        //update...
        public UpdateFrequency Update(UpdateState state)
        {
            //when pressing A, create a new avatar description
            if (state.PlayerInput[PlayerIndex.One].InputState.Buttons.A.OnPressed)
            {
                this.avatar.AvatarDescription = Microsoft.Xna.Framework.GamerServices.AvatarDescription.CreateRandom();
            }

            //if pressing B, play the cheer animation
            if (state.PlayerInput[PlayerIndex.One].InputState.Buttons.B.OnPressed)
            {
                //start or stop the cheer animation (which is a built in animation in XNA)
                //use a fadein / fadeout
                if (!cheerAnimation.AnimationFinished)
                {
                    cheerAnimation.StopAnimation(0.5f);
                }
                else
                {
                    cheerAnimation = animationController.PlayPresetAnimation(AvatarAnimationPreset.Celebrate, true, 0.5f, 0.5f);
                }
            }

            //when the cheer animation is playing, fade the walking animation out,
            //do this based on the opposite weighitng of the cheer animation (taking fading into account)
            this.walkAnimation.Weighting = 1 - this.cheerAnimation.GetFadeScaledWeighting(state);

            return(UpdateFrequency.FullUpdate60hz);
        }