static bool checkCrossFadeQueue(SpriteAnimationQueueItem item)
        {
            SpriteAnimationState fadeState = item.playMode == PlayMode.StopAll ?
                                             item.state._animation.IsAllLayerCanFade(item.fadeLength)  :
                                             item.state._animation.IsLayerCanFade(item.state.layer, item.fadeLength);

            if (fadeState != null)
            {
                item.state._animation.CrossFade(item.state, item.fadeLength, item.playMode);
                return(true);
            }

            return(false);
        }
        static bool checkCrossFadeQueue(SpriteAnimationQueueItem item)
        {
            SpriteAnimationState fadeState = item.playMode == PlayMode.StopAll ?
                item.state._animation.IsAllLayerCanFade(item.fadeLength)  :
                item.state._animation.IsLayerCanFade(item.state.layer, item.fadeLength);

            if (fadeState != null)
            {
                item.state._animation.CrossFade(item.state, item.fadeLength, item.playMode);
                return true;
            }

            return false;
        }
Beispiel #3
0
        /// <summary>
        /// Cross fades an animation after previous animations has finished playing.<br/>
        ///If queue is QueueMode.CompleteOthers this animation will only start once all other animations have stopped playing.<br/>
        ///If queue is QueueMode.PlayNow this animation will start playing immediately on a duplicated animation state.<br/>
        /// if mode is PlayMode.StopSameLayer, animations in the same layer as animation will be faded out while animation is faded in. if mode is PlayMode.StopAll, all animations will be faded out while animation is faded in.<br/>
        ///After the animation has finished playing it will automatically clean itself up. Using the duplicated animation state after it has finished will result in an exception. <br/>
        /// </summary>
        /// <param name="name">The clip name that you want to fade in.</param>
        /// <param name="fadeLength">The fade in/out length in second.</param>
        /// <param name="queue">How the clip start fade.</param>
        /// <param name="mode">How to stop the other clips.</param>
        /// <returns>The duplicated animation state of the clip.</returns>
        public SpriteAnimationState CrossFadeQueued(string name, float fadeLength, QueueMode queue, PlayMode mode)
        {
            SpriteAnimationState state = this[name];

            if (state == null)
            {
                return(null);
            }

            bool isPlaying = IsLayerPlaying(state.layer);

            if (queue == QueueMode.PlayNow || !isPlaying)
            {
                string newName = state.name + " - Queued Clone " + cloneID++;

                SpriteAnimationState tmpState = SpriteAnimationState.CreateState();
                tmpState.Clone(state, newName);


                tmpState.removeAfterStop = true;
                AddState(tmpState);

                CrossFade(tmpState, fadeLength, mode);

                return(tmpState);
            }
            else
            {
                string newName = state.name + " - Queued Clone " + cloneID++;

                SpriteAnimationState tmpState = SpriteAnimationState.CreateState();
                tmpState.Clone(state, newName);

                tmpState.removeAfterStop = true;
                AddState(tmpState);


                SpriteAnimationQueueItem item = new SpriteAnimationQueueItem();
                item.state      = tmpState;
                item.playMode   = mode;
                item.fadeLength = fadeLength;
                crossFadeQueue.Add(item);

                return(tmpState);
            }

            return(null);
        }
        /// <summary>
        /// Cross fades an animation after previous animations has finished playing.<br/>
        ///If queue is QueueMode.CompleteOthers this animation will only start once all other animations have stopped playing.<br/>
        ///If queue is QueueMode.PlayNow this animation will start playing immediately on a duplicated animation state.<br/>
        /// if mode is PlayMode.StopSameLayer, animations in the same layer as animation will be faded out while animation is faded in. if mode is PlayMode.StopAll, all animations will be faded out while animation is faded in.<br/>
        ///After the animation has finished playing it will automatically clean itself up. Using the duplicated animation state after it has finished will result in an exception. <br/>
        /// </summary>
        /// <param name="name">The clip name that you want to fade in.</param>
        /// <param name="fadeLength">The fade in/out length in second.</param>
        /// <param name="queue">How the clip start fade.</param>
        /// <param name="mode">How to stop the other clips.</param>
        /// <returns>The duplicated animation state of the clip.</returns>
        public SpriteAnimationState CrossFadeQueued(string name, float fadeLength, QueueMode queue, PlayMode mode)
        {
            SpriteAnimationState state = this[name];
            if (state == null)
                return null;

            bool isPlaying = IsLayerPlaying(state.layer);

            if (queue == QueueMode.PlayNow || !isPlaying)
            {
                string newName = state.name + " - Queued Clone " + cloneID++;

                SpriteAnimationState tmpState = new SpriteAnimationState(state, newName);
                tmpState.removeAfterStop = true;
                AddState(tmpState);

                CrossFade(tmpState, fadeLength, mode);

                return tmpState;
            }
            else
            {
                string newName = state.name + " - Queued Clone " + cloneID++;

                SpriteAnimationState tmpState = new SpriteAnimationState(state, newName);
                tmpState.removeAfterStop = true;
                AddState(tmpState);


                SpriteAnimationQueueItem item = new SpriteAnimationQueueItem();
                item.state = tmpState;
                item.playMode = mode;
                item.fadeLength = fadeLength;
                crossFadeQueue.Add(item);

                return tmpState;
            }

            return null;
        }