public SpriteBatchNodeReorder() { List <Object> a = new List <Object>(10); CCSpriteBatchNode asmtest = new CCSpriteBatchNode("animations/ghosts"); for (int i = 0; i < 10; i++) { CCSprite s1 = new CCSprite(asmtest.Texture, 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; var 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; var 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; } }
public SpriteBatchNodeReorderIssue744() { // Testing issue #744 // http://code.google.com/p/cocos2d-iphone/issues/detail?id=744 CCSpriteBatchNode batch = new CCSpriteBatchNode("Images/grossini_dance_atlas", 15); AddChild(batch, 0, (int)kTags.kTagSpriteBatchNode); sprite = new CCSprite(batch.Texture, new CCRect(0, 0, 85, 121)); batch.AddChild(sprite, 3); batch.ReorderChild(sprite, 1); }
public SpriteBatchNodeReorderIssue744() { CCSize s = CCDirector.SharedDirector.WinSize; // Testing issue #744 // http://code.google.com/p/cocos2d-iphone/issues/detail?id=744 CCSpriteBatchNode batch = new CCSpriteBatchNode("Images/grossini_dance_atlas", 15); AddChild(batch, 0, (int)kTags.kTagSpriteBatchNode); CCSprite sprite = new CCSprite(batch.Texture, 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); }
void ReorderSprite(float dt) { Unschedule(ReorderSprite); batchNode.ReorderChild(sprite1, 4); }