public SpriteBatchNodeReorder()
        {
            List <Object>     a       = new List <Object>(10);
            CCSpriteBatchNode asmtest = CCSpriteBatchNode.batchNodeWithFile("animations/images/ghosts");

            for (int i = 0; i < 10; i++)
            {
                CCSprite s1 = CCSprite.spriteWithBatchNode(asmtest, new CCRect(0, 0, 50, 50));
                a.Add(s1);
                asmtest.addChild(s1, 10);
            }

            for (int i = 0; i < 10; i++)
            {
                if (i != 5)
                {
                    asmtest.reorderChild((CCNode)(a[i]), 9);
                }
            }

            int           prev     = -1;
            List <CCNode> children = asmtest.children;
            CCSprite      child;

            foreach (var item in children)
            {
                child = (CCSprite)item;
                if (child == null)
                {
                    break;
                }

                int currentIndex = child.atlasIndex;
                Debug.Assert(prev == currentIndex - 1, "Child order failed");
                ////----UXLOG("children %x - atlasIndex:%d", child, currentIndex);
                prev = currentIndex;
            }

            prev = -1;
            List <CCSprite> sChildren = asmtest.Descendants;

            foreach (var item in sChildren)
            {
                child = (CCSprite)item;
                if (child == null)
                {
                    break;
                }

                int currentIndex = child.atlasIndex;
                Debug.Assert(prev == currentIndex - 1, "Child order failed");
                ////----UXLOG("descendant %x - atlasIndex:%d", child, currentIndex);
                prev = currentIndex;
            }

            //a.release();       //memory leak : 2010-0415
        }
        public SpriteBatchNodeReorderIssue744()
        {
            CCSize s = CCDirector.sharedDirector().getWinSize();

            // Testing issue #744
            // http://code.google.com/p/cocos2d-iphone/issues/detail?id=744
            CCSpriteBatchNode batch = CCSpriteBatchNode.batchNodeWithFile("Images/grossini_dance_atlas", 15);

            addChild(batch, 0, (int)kTags.kTagSpriteBatchNode);

            CCSprite sprite = CCSprite.spriteWithBatchNode(batch, new CCRect(0, 0, 85, 121));

            sprite.position = (new CCPoint(s.width / 2, s.height / 2));
            batch.addChild(sprite, 3);
            batch.reorderChild(sprite, 1);
        }
        public void reorderSprite(float dt)
        {
            CCSpriteBatchNode batch  = (CCSpriteBatchNode)(getChildByTag((int)kTags.kTagSpriteBatchNode));
            CCSprite          sprite = (CCSprite)(batch.getChildByTag((int)kTagSprite.kTagSprite1));

            int z = sprite.zOrder;

            if (z < -1)
            {
                m_dir = 1;
            }
            if (z > 10)
            {
                m_dir = -1;
            }

            z += m_dir * 3;

            batch.reorderChild(sprite, z);
        }