コード例 #1
0
        /// <summary>
        /// Apply the effect on the object
        /// </summary>
        /// <param name="gameTime">Time elpase since last update</param>
        public override void Apply(GameTime gameTime)
        {
            if (this.Control != null)
            {
                ITextFadeCapable fadeControl = (ITextFadeCapable)this.Control;

                //Apply text fade effect
                fadeControl.TextFade =
                    (fadeControl.FadeIn) ?
                    MathHelper.Min(fadeControl.TextFade + ((float)gameTime.ElapsedGameTime.TotalSeconds * (int)this.Speed), this._to) :
                    MathHelper.Max(fadeControl.TextFade - ((float)gameTime.ElapsedGameTime.TotalSeconds * (int)this.Speed), this._from);

                if (this.Loop && fadeControl.TextFade >= this._to)//if we loop and control fade is equal or better than the fade reach, set fade to start value
                {
                    fadeControl.TextFade = this._from;
                }
            }
        }
コード例 #2
0
 /// <summary>
 /// Create a new instance of a TextFadeEffect
 /// </summary>
 /// <param name="controle">Gui controle</param>
 /// <param name="speed">Speed of the Effect</param>
 /// <param name="from">From value of the Effect</param>
 /// <param name="to">To value of the Effect</param>
 /// <param name="loop">True if effect must loop</param>
 public TextFadeEffect(ITextFadeCapable controle, EffectSpeedEnum speed, float from, float to, bool loop = false)
     : base(controle, speed, from, to, loop)
 {
 }