Beispiel #1
0
        /// <summary>
        /// Schedules a callback for the future.
        /// Shorthand for creating an Alarm tween, starting it and adding it to a Tweener.
        /// </summary>
        /// <param name="delay">The duration to wait before calling the callback.</param>
        /// <param name="complete">The function to be called.</param>
        /// <param name="type">The tween type (PERSIST, LOOPING or ONESHOT). Defaults to ONESHOT.</param>
        /// <param name="tweener">The Tweener object to add this Alarm to. Defaults to FP.Tweener.</param>
        /// <returns>The added Alarm object.</returns>
        public static Alarm Alarm(float delay, Tween.OnComplete complete, uint type = 2, Tweener tweener = null)
        {
            tweener = tweener ?? FP.Tweener;

            var alarm = new Alarm(delay, complete, type);

            Tweener.AddTween(alarm, true);
            return(alarm);
        }
Beispiel #2
0
        /// <summary>
        /// Tweens numeric public properties of an Object.
        /// Shorthand for creating a MultiVarTween tween, starting it and adding it to a Tweener.
        /// </summary>
        /// <param name="target">The object containing the properties to tween.</param>
        /// <param name="values">An object containing key/value pairs of properties and target values.</param>
        /// <param name="duration">Duration of the tween.</param>
        /// <param name="options">An object containing key/value pairs of the following optional parameters:
        ///                             type        Tween type.
        ///                             complete    Optional completion callback function.
        ///                             ease        Optional easer function.
        ///                             tweener     The Tweener to add this Tween to.
        ///                             delay       A length of time to wait before starting this tween.
        /// </param>
        /// <example>FP.Tween(object, new { x = 500, y = 350 }, 2.0f, new { ease = easeFunction, complete = onComplete } );</example>
        /// <returns>The added MultiVarTween object.</returns>
        public static MultiVarTween Tween(object target, object values, float duration, object options = null)
        {
            uint type = Punk.Tween.ONESHOT;

            Tween.OnComplete complete = null;
            Tween.Easer      ease     = null;
            Tweener          tweener  = FP.Tweener;
            float            delay    = 0;

            if (target is Tweener)
            {
                tweener = target as Tweener;
            }

            if (options != null)
            {
                if (options is Tween.OnComplete)
                {
                    complete = options as Tween.OnComplete;
                }
                if (options.HasOwnProperty("type"))
                {
                    type = options.GetProp <uint>("type");
                }
                if (options.HasOwnProperty("complete"))
                {
                    complete = options.GetProp <Tween.OnComplete>("complete");
                }
                if (options.HasOwnProperty("ease"))
                {
                    ease = options.GetProp <Tween.Easer>("ease");
                }
                if (options.HasOwnProperty("tweener"))
                {
                    tweener = options.GetProp <Tweener>("tweener");
                }
                if (options.HasOwnProperty("delay"))
                {
                    delay = options.GetProp <float>("delay");
                }
            }

            var tween = new MultiVarTween(complete, type);

            tween.Tween(target, values, duration, ease, delay);
            tweener.AddTween(tween);
            return(tween);
        }