示例#1
0
        public DisplayObject RemoveChildAt(int index, bool dispose)
        {
            if (index >= 0 && index < _children.Count)
            {
                DisplayObject child = _children[index];

                if (stage != null)
                {
                    if (child is Container)
                    {
                        child.onRemovedFromStage.BroadcastCall();
                    }
                    else
                    {
                        child.onRemovedFromStage.Call();
                    }
                }
                _children.Remove(child);
                child.SetParent(null);
                InvalidateBatchingState();
                if (dispose)
                {
                    child.Dispose();
                }

                return(child);
            }
            else
            {
                throw new Exception("Invalid child index");
            }
        }
示例#2
0
        public DisplayObject AddChildAt(DisplayObject child, int index)
        {
            int count = _children.Count;

            if (index >= 0 && index <= count)
            {
                if (child.parent == this)
                {
                    SetChildIndex(child, index);
                }
                else
                {
                    child.RemoveFromParent();
                    if (index == count)
                    {
                        _children.Add(child);
                    }
                    else
                    {
                        _children.Insert(index, child);
                    }
                    child.SetParent(this);
                    child.tmpZ = 0;

                    if (stage != null)
                    {
                        if (child is Container)
                        {
                            child.onAddedToStage.BroadcastCall();
                        }
                        else
                        {
                            child.onAddedToStage.Call();
                        }
                    }

                    InvalidateBatchingState();
                }
                return(child);
            }
            else
            {
                throw new Exception("Invalid child index");
            }
        }
        public DisplayObject AddChildAt(DisplayObject child, int index)
        {
            int count = _children.Count;
            if (index >= 0 && index <= count)
            {
                if (child.parent == this)
                {
                    SetChildIndex(child, index);
                }
                else
                {
                    child.RemoveFromParent();
                    if (index == count)
                        _children.Add(child);
                    else
                        _children.Insert(index, child);
                    child.SetParent(this);

                    if (stage != null)
                    {
                        if (child is Container)
                            child.onAddedToStage.BroadcastCall();
                        else
                            child.onAddedToStage.Call();
                    }

                    InvalidateBatchingState(true);
                }
                return child;
            }
            else
            {
                throw new Exception("Invalid child index");
            }
        }