Example #1
0
        public Vector2Tweener( 
			Vector2 start, 
			Vector2 end, 
			TimeSpan duration, 
			TweeningFunction tweeningFunction )
        {
            _tweenerX = new Tweener( start.X, end.X, duration, tweeningFunction ) ;
            _tweenerY = new Tweener( start.Y, end.Y, duration, tweeningFunction) ;

            _tweenerX.Ended += ( ) =>
                               	{
                               		if( _tweenerY.HasEnded )
                               		{
                               			if( Ended != null )
                               			{
                               				Ended( ) ;
                               			}
                               		}
                               	};

            _tweenerY.Ended += ( ) =>
                               	{
                               		if( _tweenerX.HasEnded )
                               		{
                               			if( Ended != null )
                               			{
                               				Ended( ) ;
                               			}
                               		}
                               	};
        }
Example #2
0
        public Vector2Tweener(
            Vector2 start,
            Vector2 end,
            TimeSpan duration,
            TweeningFunction tweeningFunction)
        {
            _tweenerX = new Tweener(start.X, end.X, duration, tweeningFunction);
            _tweenerY = new Tweener(start.Y, end.Y, duration, tweeningFunction);

            _tweenerX.Ended += () =>
            {
                if (_tweenerY.HasEnded)
                {
                    if (Ended != null)
                    {
                        Ended( );
                    }
                }
            };

            _tweenerY.Ended += () =>
            {
                if (_tweenerX.HasEnded)
                {
                    if (Ended != null)
                    {
                        Ended( );
                    }
                }
            };
        }
Example #3
0
 public Tweener(float from, float to, float duration, TweeningFunction tweeningFunction)
 {
     _from             = from;
     _position         = from;
     _change           = to - from;
     _tweeningFunction = tweeningFunction;
     _duration         = duration;
 }
Example #4
0
 /// <summary>
 /// Create a Tweener with info on where to move from and to, how long it should take and the function to use.
 /// </summary>
 /// <param name="from">The starting position</param>
 /// <param name="to">The position reached at the end</param>
 /// <param name="duration">How long befor we reach the end?</param>
 /// <param name="tweeningFunction">Which function to use for calculating the current position.</param>
 protected BaseTweener(T from, T to, float duration, TweeningFunction tweeningFunction)
 {
     _from             = from;
     _position         = from;
     _change           = CalculateChange(to, from);
     _tweeningFunction = tweeningFunction;
     _duration         = duration;
 }
Example #5
0
 /// <summary>
 /// Create a stopped tweener with no information on where to move from and to.
 /// Useful in conjunction with the Reset(from, to) call to ready a tweener for later use or lazy
 /// instantiation of a tweener in a property.
 /// </summary>
 /// <param name="duration">The duration of tweening.</param>
 /// <param name="tweeningFunction">Which function to use for calculating the current position.</param>
 protected BaseTweener(T from, T to, TweeningFunction tweeningFunction, float speed)
 {
     _from             = from;
     _position         = from;
     _change           = CalculateChange(to, from);
     _tweeningFunction = tweeningFunction;
     _duration         = CalculateDurationFromSpeed(speed);
 }
Example #6
0
 public Tweener(float from, float to, float duration, TweeningFunction tweeningFunction)
 {
     _from = from;
     _position = from;
     _change = to - from;
     _tweeningFunction = tweeningFunction;
     _duration = duration;
 }
Example #7
0
 private TweenLite(float from, float to, float duration, TweeningFunction tweeningFunction, Action <float> onupdate)
 {
     _from             = from;
     _position         = from;
     _change           = to - from;
     _tweeningFunction = tweeningFunction;
     _duration         = duration;
     _onupdate         = onupdate;
 }
Example #8
0
 /// <summary>
 /// Create a Tweener with info on where to move from and to, how long it should take and the function to use.
 /// </summary>
 /// <param name="from">The starting position</param>
 /// <param name="to">The position reached at the end</param>
 /// <param name="duration">How long befor we reach the end?</param>
 /// <param name="tweeningFunction">Which function to use for calculating the current position.</param>
 protected BaseTweener(string propertyName, T from, T to, float duration, TweeningFunction tweeningFunction)
 {
     PropertyName          = propertyName;
     this.@from            = from;
     _position             = from;
     change                = CalculateChange(to, from);
     this.tweeningFunction = tweeningFunction;
     _duration             = duration;
 }
Example #9
0
        public TweenPositionTo(BaseEntity entity, Vector2 to, float duration, TweeningFunction tween)
        {
            this.entity = entity;
            this.to = to;
            this.duration = duration;
            this.tween = tween;

            isComplete = false;
        }
        public TweenPositionToEntity(BaseEntity entity, BaseEntity to, Point offset, float duration, TweeningFunction tween)
        {
            this.entity = entity;
            this.to = to;
            this.offset = offset;
            this.duration = duration;
            this.tween = tween;

            isComplete = false;
        }
Example #11
0
 public Tweener(float from, float to, float duration, TweeningFunction tweeningFunction)
 {
     From = from;
     Position = from;
     Change = to - from;
     Function = tweeningFunction;
     Duration = duration;
     Elapsed = 0.0f;
     Running = true;
 }
Example #12
0
        public void Start(float from, float to, float duration, TweeningFunction tweeningFunction)
        {
            _from             = from;
            _position         = from;
            _change           = to - from;
            _tweeningFunction = tweeningFunction;
            Duration          = duration;
            _elapsed          = 0;

            Running = true;
        }
Example #13
0
    public Tweener(float from, float to, float duration, TweeningFunction tweeningFunction)
    {
        _tweeningFunction = tweeningFunction;

        Running   = true;
        _elapsed  = 0.0f;
        _from     = @from;
        _to       = to;
        Position  = @from;
        _change   = to - @from;
        _duration = duration;
    }
Example #14
0
        public static TweenLite To(Vector2 from, Vector2 to, float duration, TweeningFunction tweeningFunction, Action <Vector2> onupdate, Action onend = null)
        {
            float _x      = 0;
            var   _xTween = TweenLite.To(from.x, to.x, duration, tweeningFunction, v => _x = v);
            var   _yTween = TweenLite.To(from.y, to.y, duration, tweeningFunction, _y => onupdate?.Invoke(new Vector2(_x, _y)), onend);

            _yTween.BeforeRelease += () =>
            {
                _xTween.Release();
            };

            return(_yTween);
        }
Example #15
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="from">起始值</param>
 /// <param name="to">结束值</param>
 /// <param name="duration">缓动时间(单位:毫秒)</param>
 /// <param name="tweeningFunction">缓动方式</param>
 /// <param name="onupdate">
 /// 每帧Update的回调
 /// 参数 float 标示当前的插值
 /// </param>
 /// <param name="onend">缓动结束时的回调</param>
 /// <returns></returns>
 public static TweenLite To(float from, float to, float duration, TweeningFunction tweeningFunction, Action <float> onupdate, Action onend = null)
 {
     lock (m_tasklock)
     {
         var tween = new TweenLite(from, to, duration, tweeningFunction, onupdate);
         if (onend != null)
         {
             tween.Ended += () => { onend(); }
         }
         ;
         m_tweeners.Add(tween);
         return(tween);
     }
 }
Example #16
0
    public Marquee(MarqueeText[] texts)
    {
        _timer = new(1000.Seconds());
        _texts = texts;
        _index = -1;
        selectNext();

        _tweeningFunction = Tweener.CreateTweeningFunction <Elastic>(Easing.EaseInOut);

        var colorTweeningFunction = Tweener.CreateTweeningFunction <Linear>(Easing.EaseNone);

        _colorTweener        = new(.33f, 1, .33f.Seconds(), colorTweeningFunction);
        _colorTweener.Ended += () =>
        {
            _colorTweener.Reverse();
            _colorTweener.Reset();
        };
    }
Example #17
0
        public static TweenLite To(Color from, Color to, float duration, TweeningFunction tweeningFunction, Action <Color> onupdate, Action onend = null)
        {
            float r       = 0;
            float g       = 0;
            float b       = 0;
            var   _rTween = TweenLite.To(from.r, to.r, duration, tweeningFunction, v => r = v);
            var   _gTween = TweenLite.To(from.g, to.g, duration, tweeningFunction, v => g = v);
            var   _bTween = TweenLite.To(from.b, to.b, duration, tweeningFunction, v => b = v);
            var   _aTween = TweenLite.To(from.a, to.a, duration, tweeningFunction, a => onupdate?.Invoke(new Color(r, g, b, a)), onend);

            _aTween.BeforeRelease += () =>
            {
                _rTween.Release();
                _gTween.Release();
                _bTween.Release();
            };

            return(_aTween);
        }
Example #18
0
 public Tweener(float from, float to, float duration, TweeningFunction tweeningFunction)
 {
     Start(from, to, duration, tweeningFunction);
     // Start sets Running to true, so let's set it to false
     Running = false;
 }
Example #19
0
 /// <summary>
 /// Create a Tweener with info on where to move from and to, but set the duration using the movement
 /// speed instead of a set timespan.
 /// Note that the speed is used to calculate how fast the tweener should move if it moved in a linear
 /// fashion. This can be upset by the tweening function that can cause the actual movement speed to vary
 /// considerably. So the speed can be looked at as an average speed during the lifetime of the tweener.
 /// </summary>
 /// <param name="from">The starting position</param>
 /// <param name="to">The position reached at the end</param>
 /// <param name="duration">The average movement speed of the tweener</param>
 /// <param name="tweeningFunction">Which function to use for calculating the current position.</param>
 public Tweener(float from, float to, TweeningFunction tweeningFunction, float speed)
     : base(from, to, tweeningFunction, speed)
 {
 }
Example #20
0
 private TweenLite(float from, float to, TimeSpan duration, TweeningFunction tweeningFunction, Action <float> onupdate)
     : this(from, to, (float)duration.TotalSeconds, tweeningFunction, onupdate)
 {
 }
Example #21
0
 /// <summary>
 /// Create a stopped tweener with no information on where to move from and to.
 /// Useful in conjunction with the Reset(from, to) call to ready a tweener for later use or lazy
 /// instantiation of a tweener in a property.
 /// </summary>
 /// <param name="duration">The duration of tweening.</param>
 /// <param name="tweeningFunction">Which function to use for calculating the current position.</param>
 protected BaseTweener(TweeningFunction tweeningFunction)
 {
     _tweeningFunction = tweeningFunction;
     _playing          = false;
 }
Example #22
0
 public Tweener(float from, float to, TimeSpan duration, TweeningFunction tweeningFunction)
     : this(from, to, (float)duration.TotalSeconds, tweeningFunction)
 {
 }
Example #23
0
        public Tweener(float from, float to, TimeSpan duration, TweeningFunction tweeningFunction)
            : this(from, to, (float)duration.TotalSeconds, tweeningFunction)
        {

        }
Example #24
0
 /// <summary>
 /// Create a Tweener with info on where to move from and to, how long it should take and the function to use.
 /// </summary>
 /// <param name="from">The starting position</param>
 /// <param name="to">The position reached at the end</param>
 /// <param name="duration">How long befor we reach the end?</param>
 /// <param name="tweeningFunction">Which function to use for calculating the current position.</param>
 public Vector3Tweener(Vector3 from, Vector3 to, TimeSpan duration, TweeningFunction tweeningFunction)
     : base(from, to, (float)duration.TotalSeconds, tweeningFunction)
 {
 }
Example #25
0
 /// <summary>
 /// Create a Tweener with info on where to move from and to, but set the duration using the movement
 /// speed instead of a set timespan.
 /// Note that the speed is used to calculate how fast the tweener should move if it moved in a linear
 /// fashion. This can be upset by the tweening function that can cause the actual movement speed to vary
 /// considerably. So the speed can be looked at as an average speed during the lifetime of the tweener.
 /// </summary>
 /// <param name="from">The starting position</param>
 /// <param name="to">The position reached at the end</param>
 /// <param name="duration">The average movement speed of the tweener</param>
 /// <param name="tweeningFunction">Which function to use for calculating the current position.</param>
 public Vector3Tweener(Vector3 from, Vector3 to, TweeningFunction tweeningFunction, float speed)
     : base(from, to, tweeningFunction, speed)
 {
 }
Example #26
0
 /// <summary>
 /// Create a Tweener with info on where to move from and to, how long it should take and the function to use.
 /// </summary>
 /// <param name="from">The starting position</param>
 /// <param name="to">The position reached at the end</param>
 /// <param name="duration">How long befor we reach the end?</param>
 /// <param name="tweeningFunction">Which function to use for calculating the current position.</param>
 public ColorTweener(Color from, Color to, float duration, TweeningFunction tweeningFunction)
     : base(from, to, duration, tweeningFunction)
 {
 }
Example #27
0
        public void start()
        {
            _startTime = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
            _startTime += _delayTime;
            if (_tweenFunc == null)
                _tweenFunc = Tweener.GetFunction(TransitionType.LINEAR);

            if (_startVal == -1)
                _startVal = float.Parse(_prop.GetValue(_object, null).ToString());
        }
Example #28
0
 /// <summary>
 /// Create a Tweener with info on where to move from and to, but set the duration using the movement
 /// speed instead of a set timespan.
 /// Note that the speed is used to calculate how fast the tweener should move if it moved in a linear
 /// fashion. This can be upset by the tweening function that can cause the actual movement speed to vary
 /// considerably. So the speed can be looked at as an average speed during the lifetime of the tweener.
 /// </summary>
 /// <param name="from">The starting position</param>
 /// <param name="to">The position reached at the end</param>
 /// <param name="duration">The average movement speed of the tweener</param>
 /// <param name="tweeningFunction">Which function to use for calculating the current position.</param>
 public ColorTweener(Color from, Color to, TweeningFunction tweeningFunction, float speed)
     : base(from, to, tweeningFunction, speed)
 {
 }
Example #29
0
 /// <summary>
 /// Create a stopped tweener with no information on where to move from and to.
 /// Useful in conjunction with the Reset(from, to) call to ready a tweener for later use or lazy
 /// instantiation of a tweener in a property.
 /// </summary>
 /// <param name="duration">The duration of tweening.</param>
 /// <param name="tweeningFunction">Which function to use for calculating the current position.</param>
 public ColorTweener(TweeningFunction tweeningFunction)
     : base(tweeningFunction)
 {
 }
Example #30
0
 /// <summary>
 /// Create a Tweener with info on where to move from and to, how long it should take and the function to use.
 /// </summary>
 /// <param name="from">The starting position</param>
 /// <param name="to">The position reached at the end</param>
 /// <param name="duration">How long befor we reach the end?</param>
 /// <param name="tweeningFunction">Which function to use for calculating the current position.</param>
 public ColorTweener(Color from, Color to, TimeSpan duration, TweeningFunction tweeningFunction)
     : base(from, to, (float)duration.TotalSeconds, tweeningFunction)
 {
 }
Example #31
0
 /// <summary>
 /// Create a Tweener with info on where to move from and to, how long it should take and the function to use.
 /// </summary>
 /// <param name="from">The starting position</param>
 /// <param name="to">The position reached at the end</param>
 /// <param name="duration">How long befor we reach the end?</param>
 /// <param name="tweeningFunction">Which function to use for calculating the current position.</param>
 public Vector3Tweener(Vector3 from, Vector3 to, float duration, TweeningFunction tweeningFunction)
     : base(from, to, duration, tweeningFunction)
 {
 }
Example #32
0
 protected CAAnimation(string propertyName, float from, float to, TimeSpan duration, TweeningFunction tweeningFunction) : base(propertyName, from, to, duration, tweeningFunction)
 {
 }
Example #33
0
 /// <summary>
 /// Create a stopped tweener with no information on where to move from and to.
 /// Useful in conjunction with the Reset(from, to) call to ready a tweener for later use or lazy
 /// instantiation of a tweener in a property.
 /// </summary>
 /// <param name="duration">The duration of tweening.</param>
 /// <param name="tweeningFunction">Which function to use for calculating the current position.</param>
 public Vector3Tweener(TweeningFunction tweeningFunction)
     : base(tweeningFunction)
 {
 }
Example #34
0
 protected CAAnimation(TweeningFunction tweeningFunction) : base(tweeningFunction)
 {
 }
Example #35
0
        public Tweener(float from, float to, float duration, TweeningFunction tweeningFunction)
        {
            this.tweeningFunction = tweeningFunction;

            Initialise(from, to, duration);
        }
Example #36
0
 protected CAAnimation(string propertyName, float from, float to, TweeningFunction tweeningFunction, float speed)
     : base(propertyName, from, to, tweeningFunction, speed)
 {
 }
Example #37
0
 public Tweener(float from, float to, float duration, TweeningFunction tweeningFunction)
 {
     Start(from, to, duration, tweeningFunction);
     // Start sets Running to true, so let's set it to false
     Running = false;
 }
Example #38
0
 public TweenData(object o, string property_name, float startVal, float endVal, int duration, TransitionType transitionType)
 {
     this._object = o;
     this._prop = _object.GetType().GetProperty(property_name);
     _startVal = startVal;
     _endVal = endVal == -1 ? float.Parse(_prop.GetValue(_object, null).ToString()) : endVal;
     _duration = duration;
     _property_name = property_name;
     _tweenFunc = Tweener.GetFunction(transitionType);
 }
Example #39
0
        public void Start(float from, float to, float duration, TweeningFunction tweeningFunction)
        {
            _from = from;
            _position = from;
            _change = to - from;
            _tweeningFunction = tweeningFunction;
            Duration = duration;
            _elapsed = 0;

            Running = true;

        }
Example #40
0
 /// <summary>
 /// Create a Tweener with info on where to move from and to, how long it should take and the function to use.
 /// </summary>
 /// <param name="from">The starting position</param>
 /// <param name="to">The position reached at the end</param>
 /// <param name="duration">How long befor we reach the end?</param>
 /// <param name="tweeningFunction">Which function to use for calculating the current position.</param>
 protected BaseTweener(T from, T to, TimeSpan duration, TweeningFunction tweeningFunction)
     : this(from, to, (float)duration.TotalSeconds, tweeningFunction)
 {
 }