Ejemplo n.º 1
0
        /// <summary>
        /// Changes the SkeletonSet used to animate.
        /// </summary>
        /// <param name="newSet">New SkeletonSet to use.</param>
        public void ChangeSet(SkeletonSet newSet)
        {
            if (newSet == null)
            {
                Debug.Fail("newSet is null.");
                return;
            }
            if (newSet.KeyFrames.Length == 0)
            {
                Debug.Fail("newSet contains no KeyFrames.");
                return;
            }

            // Set the new animation and clear the frame count
            _frame     = 0;
            _nextFrame = newSet.KeyFrames[0];
            _skelSet   = newSet;

            // Create a temporary new current keyframe by duplicating the current state and making
            // that our new current keyframe, resulting in a smooth translation to the next animation
            float delay;

            if (CurrentFrame.Delay == 0)
            {
                delay = _nextFrame.Delay;
            }
            else
            {
                delay = CurrentFrame.Delay;
            }

            _currFrame = new SkeletonFrame("_worker_", _skel.DeepCopy(), delay);
        }