コード例 #1
0
        void ReparentSprite(float dt)
        {
            CCNode p1 = GetChildByTag((int)kTags.kTagNode);
            CCNode p2 = GetChildByTag((int)kTags.kTagSpriteBatchNode);

            List <CCNode> retArray = new List <CCNode>(250);

            if (usingSpriteBatchNode)
            {
                CCNode tmp = p1;
                p1 = p2;
                p2 = tmp;
            }

            ////----UXLOG("New parent is: %x", p2);

            CCNode node;
            var    children = p1.Children;

            foreach (var item in children)
            {
                if (item == null)
                {
                    break;
                }
                retArray.Add(item);
            }

            int i = 0;

            p1.RemoveAllChildren(false);

            foreach (var item in retArray)
            {
                if (item == null)
                {
                    break;
                }
                p2.AddChild(item, i, i);
                i++;
            }

            usingSpriteBatchNode = !usingSpriteBatchNode;
        }