Create() public static method

Creates a new Interpolator.
public static Create ( float start, float end, float length, Action step, Action completed ) : Interpolator
start float The starting value.
end float The ending value.
length float The length of time, in seconds, to perform the interpolation.
step Action An optional callback to invoke when the Interpolator is updated.
completed Action An optional callback to invoke when the Interpolator completes.
return Interpolator
Esempio n. 1
0
        /// <summary>
        ///   Fades the whole Application screen out.
        /// </summary>
        /// <param name = "endColor">The Color used for end</param>
        /// <param name = "length">The length in seconds the fade operation should last</param>
        public static void FadeOut(Color endColor, float length)
        {
            if (_fadeActive)
            {
                Debug.WriteLine("Fading already active");
                return;
            }

            if (_hideActive)
            {
                Debug.WriteLine("Screen already hidden");
                return;
            }

            _fadeActive = true;

            Instance._transitionColor = endColor * 0f;

            Interpolator.Create(0.0f, 1.0f, length,
                                (step) =>
            {
                Instance._transitionColor = new Color(Convert.ToSingle(Instance._transitionColor.R),
                                                      Convert.ToSingle(Instance._transitionColor.G),
                                                      Convert.ToSingle(Instance._transitionColor.B),
                                                      step.Value);
            }, completed =>
            {
                _fadeActive = false;
                _hideActive = true;
            });
        }
Esempio n. 2
0
        /// <summary>
        ///   Fades the whole Application screen in.
        /// </summary>
        /// <param name = "startColor">The Color used for start</param>
        /// <param name = "length">The length in seconds the fade operation should last</param>
        public static void FadeIn(Color startColor, float length)
        {
            if (_fadeActive)
            {
                Debug.WriteLine("Fading already active");
                return;
            }

            //
            if (_hideActive)
            {
                _hideActive = false;
            }
            _fadeActive = true;

            Instance._transitionColor = startColor;

            Interpolator.Create(1.0f, 0.0f, length,
                                (step) =>
            {
                Instance._transitionColor = new Color(Convert.ToSingle(Instance._transitionColor.R),
                                                      Convert.ToSingle(Instance._transitionColor.G),
                                                      Convert.ToSingle(Instance._transitionColor.B),
                                                      step.Value);
            }, completed => _fadeActive = false);
        }