Exemple #1
0
        /// <summary>
        /// Whether this tween handles rotation.
        /// </summary>
        /// <returns>A reference to this.</returns>
        public Tween Rotation(RotationUnit unit = RotationUnit.Degrees)
        {
            behavior |= GlideLerper.Behavior.Rotation;
            behavior |= (unit == RotationUnit.Degrees) ? GlideLerper.Behavior.RotationDegrees : GlideLerper.Behavior.RotationRadians;

            return(this);
        }
                public override object Interpolate(float t, object current, GlideLerper.Behavior behavior)
                {
                    var value = from + range * t;

                    if (behavior.HasFlag(GlideLerper.Behavior.Rotation))
                    {
                        if (behavior.HasFlag(GlideLerper.Behavior.RotationRadians))
                        {
                            value *= Util.DEG_TO_RAD;
                        }

                        value %= 360.0f;

                        if (value < 0)
                        {
                            value += 360.0f;
                        }

                        if (behavior.HasFlag(GlideLerper.Behavior.RotationRadians))
                        {
                            value *= Util.RAD_TO_DEG;
                        }
                    }

                    if (behavior.HasFlag(GlideLerper.Behavior.Round))
                    {
                        value = (float)Math.Round(value);
                    }

                    var type = current.GetType();

                    return(Convert.ChangeType(value, type));
                }
                public override void Initialize(object fromValue, object toValue, GlideLerper.Behavior behavior)
                {
                    from  = Convert.ToSingle(fromValue);
                    to    = Convert.ToSingle(toValue);
                    range = to - from;

                    if (behavior.HasFlag(GlideLerper.Behavior.Rotation))
                    {
                        float angle = from;
                        if (behavior.HasFlag(GlideLerper.Behavior.RotationRadians))
                        {
                            angle *= Util.DEG_TO_RAD;
                        }

                        if (angle < 0)
                        {
                            angle = 360 + angle;
                        }

                        float r = angle + range;
                        float d = r - angle;
                        float a = (float)Math.Abs(d);

                        if (a >= 180)
                        {
                            range = (360 - a) * (d > 0 ? -1 : 1);
                        }
                        else
                        {
                            range = d;
                        }
                    }
                }
Exemple #4
0
        private Tween(object target, float duration, float delay, Tween.TweenerImpl parent) {
            Target = target;
            Duration = duration;
            Delay = delay;
            Parent = parent;
            Remover = parent;

            firstUpdate = true;

            varHash = new Dictionary<string, int>();
            vars = new List<GlideInfo>();
            lerpers = new List<GlideLerper>();
            start = new List<object>();
            end = new List<object>();
            behavior = GlideLerper.Behavior.None;
        }
Exemple #5
0
        private Tween(object target, float duration, float delay, Tween.TweenerImpl parent)
        {
            Target   = target;
            Duration = duration;
            Delay    = delay;
            Parent   = parent;
            Remover  = parent;

            firstUpdate = true;

            varHash  = new Dictionary <string, int>();
            vars     = new List <GlideInfo>();
            lerpers  = new List <GlideLerper>();
            start    = new List <object>();
            end      = new List <object>();
            behavior = GlideLerper.Behavior.None;
        }
Exemple #6
0
 /// <summary>
 /// Whether tweened values should be rounded to integer values.
 /// </summary>
 /// <returns>A reference to this.</returns>
 public Tween Round()
 {
     behavior |= GlideLerper.Behavior.Round;
     return(this);
 }
Exemple #7
0
 /// <summary>
 /// Sets the tween to reverse every other time it repeats. Repeating must be enabled for this to have any effect.
 /// </summary>
 /// <returns>A reference to this.</returns>
 public Tween Reflect()
 {
     behavior |= GlideLerper.Behavior.Reflect;
     return(this);
 }
Exemple #8
0
 /// <summary>
 /// Whether tweened values should be rounded to integer values.
 /// </summary>
 /// <returns>A reference to this.</returns>
 public Tween Round() {
     behavior |= GlideLerper.Behavior.Round;
     return this;
 }
Exemple #9
0
        /// <summary>
        /// Whether this tween handles rotation.
        /// </summary>
        /// <returns>A reference to this.</returns>
        public Tween Rotation(RotationUnit unit = RotationUnit.Degrees) {
            behavior |= GlideLerper.Behavior.Rotation;
            behavior |= (unit == RotationUnit.Degrees) ? GlideLerper.Behavior.RotationDegrees : GlideLerper.Behavior.RotationRadians;

            return this;
        }
Exemple #10
0
 /// <summary>
 /// Sets the tween to reverse every other time it repeats. Repeating must be enabled for this to have any effect.
 /// </summary>
 /// <returns>A reference to this.</returns>
 public Tween Reflect() {
     behavior |= GlideLerper.Behavior.Reflect;
     return this;
 }