Example #1
0
        /// <summary>
        /// Adds a child to a sequence or group
        /// </summary>
        /// <param name="child">child to add</param>
        public Animation Child(Animation child)
        {
            if (child._parent != null)
            {
                throw new ArgumentException("Child already has a parent");
            }

            child.SetParent(this);
            return(this);
        }
Example #2
0
        /// <summary>
        /// Stop the given animation.
        /// </summary>
        /// <param name="anim"></param>
        private static void Stop(Animation anim)
        {
            if ((anim._flags & Flags.Stopping) == Flags.Stopping)
            {
                return;
            }

            anim._flags |= Flags.Stopping;

            // Stop all children
            while (anim._firstChild != null)
            {
                Stop(anim._firstChild);
            }

            anim.SetParent(null);
            anim.IsActive = false;

            var onStop = anim._onStop;
            var target = anim._target;

            // Free the animation
            FreeAnimation(anim);

            // Auto-destroy the node
            if (anim.IsAutoDestroy)
            {
                if (target is Node node)
                {
                    node.Destroy();
                }
            }

            // Call onStop
            onStop?.Invoke();
        }