// ------------------------------------------------------------------------- // Helpers // ------------------------------------------------------------------------- private void Reset() { _target = null; _tweenType = PositionType.NONE; _equation = null; _isReversed = false; _isInitialized = false; _isPooled = false; _combinedTweenCount = 0; _delayMillis = 0; _isStarted = false; _isDelayEnded = false; _isEnded = false; _isFinished = true; _completeCallbacks.Clear(); _iterationCompleteCallbacks.Clear(); _killCallbacks.Clear(); _poolCallbacks.Clear(); _startCallbacks.Clear(); _endOfDelayCallbacks.Clear(); _repeatCnt = 0; _iteration = 0; _repeatDelayMillis = 0; _userData = null; }
// ------------------------------------------------------------------------- // Ctor // ------------------------------------------------------------------------- /** * Instantiates a new Tween from scratch. * @param target The target of the interpolation. * @param tweenType The desired type of interpolation. * @param durationMillis The duration of the interpolation, in milliseconds. * @param equation The easing equation used during the interpolation. */ public Tween(ITweenable target, PositionType tweenType, int durationMillis, TweenEquation equation) { _startValues = new float[MaxCombinedTweens]; _targetValues = new float[MaxCombinedTweens]; _targetMinusStartValues = new float[MaxCombinedTweens]; _startCallbacks = new List <ITweenCallback>(3); _endOfDelayCallbacks = new List <ITweenCallback>(3); _iterationCompleteCallbacks = new List <ITweenCallback>(3); _completeCallbacks = new List <ITweenCallback>(3); _killCallbacks = new List <ITweenCallback>(3); _poolCallbacks = new List <ITweenCallback>(3); Reset(); __build(target, tweenType, durationMillis, equation); }
// ------------------------------------------------------------------------- // Expert features // ------------------------------------------------------------------------- /** * <b>Advanced use.</b> * <br/>Rebuilds a tween from the current one. May be used if you want to * build your own pool system. You should call __reset() before. */ public void __build(ITweenable target, PositionType tweenType, int durationMillis, TweenEquation equation) { Reset(); _isInitialized = true; _target = target; _tweenType = tweenType; _durationMillis = durationMillis; _equation = equation; if (target != null) { _combinedTweenCount = target.GetTweenValues(tweenType, _localTmp); if ((_combinedTweenCount < 1) || (_combinedTweenCount > MaxCombinedTweens)) { throw new Exception("Min combined tweens = 1, max = " + MaxCombinedTweens); } } }
protected internal override void Reset() { base.Reset(); target = null; targetClass = null; accessor = null; type = -1; equation = null; path = null; isFrom = isRelative = false; combinedAttrsCnt = waypointsCnt = 0; if (accessorBuffer.Length != combinedAttrsLimit) { accessorBuffer = new float[combinedAttrsLimit]; } if (pathBuffer.Length != (2 + waypointsLimit) * combinedAttrsLimit) { pathBuffer = new float[(2 + waypointsLimit) * combinedAttrsLimit]; } }
/** * @param target The target of the interpolation. * @param tweenType The desired type of interpolation. * @param durationMillis The duration of the interpolation, in milliseconds. * @param equation The easing equation used during the interpolation. * @return The generated Tween. */ public static Tween From(ITweenable target, PositionType tweenType, int durationMillis, TweenEquation equation) { var tween = Pool.Get(); tween.Reset(); tween.__build(target, tweenType, durationMillis, equation); tween._isPooled = _isPoolEnabled; tween.Reverse(); return(tween); }
// ------------------------------------------------------------------------- // Public API // ------------------------------------------------------------------------- /// <summary>Sets the easing equation of the tween.</summary> /// <remarks> /// Sets the easing equation of the tween. Existing equations are located in /// <i>aurelienribon.tweenengine.equations</i> package, but you can of course /// implement your owns, see /// <see cref="TweenEquation">TweenEquation</see> /// . You can also use the /// <see cref="TweenEquations">TweenEquations</see> /// static instances to quickly access all the /// equations. Default equation is Quad.INOUT. /// <p/> /// <b>Proposed equations are:</b><br/> /// - Linear.INOUT,<br/> /// - Quad.IN | OUT | INOUT,<br/> /// - Cubic.IN | OUT | INOUT,<br/> /// - Quart.IN | OUT | INOUT,<br/> /// - Quint.IN | OUT | INOUT,<br/> /// - Circ.IN | OUT | INOUT,<br/> /// - Sine.IN | OUT | INOUT,<br/> /// - Expo.IN | OUT | INOUT,<br/> /// - Back.IN | OUT | INOUT,<br/> /// - Bounce.IN | OUT | INOUT,<br/> /// - Elastic.IN | OUT | INOUT /// </remarks> /// <returns>The current tween, for chaining instructions.</returns> /// <seealso cref="TweenEquation">TweenEquation</seealso> /// <seealso cref="TweenEquations">TweenEquations</seealso> public TweenEngine.Tween Ease(TweenEquation easeEquation) { this.equation = easeEquation; return(this); }