MCPcopy Create free account
hub / github.com/axmolengine/axmol / SpriteBatchNodeReorder

Method SpriteBatchNodeReorder

tests/cpp-tests/Source/SpriteTest/SpriteTest.cpp:714–757  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

712//------------------------------------------------------------------
713
714SpriteBatchNodeReorder::SpriteBatchNodeReorder()
715{
716 Vector<Sprite*> a;
717 auto asmtest = SpriteBatchNode::create("animations/ghosts.png");
718
719 for (int i = 0; i < 10; i++)
720 {
721 auto s1 = Sprite::createWithTexture(asmtest->getTexture(), Rect(0.0f, 0.0f, 50.0f, 50.0f));
722 a.pushBack(s1);
723 asmtest->addChild(s1, 10);
724 }
725
726 for (int i = 0; i < 10; i++)
727 {
728 if (i != 5)
729 {
730 asmtest->reorderChild(static_cast<Node*>(a.at(i)), 9);
731 }
732 }
733
734 ssize_t AX_UNUSED prev = -1;
735
736 auto& children = asmtest->getChildren();
737
738 for (const auto& obj : children)
739 {
740 auto child = static_cast<Sprite*>(obj);
741
742 ssize_t currentIndex = child->getAtlasIndex();
743 AXASSERT(prev == currentIndex - 1, "Child order failed");
744 ////----AXLOGD("children {:#x} - atlasIndex:{}", child, currentIndex);
745 prev = currentIndex;
746 }
747
748 prev = -1;
749 auto& descendants = asmtest->getDescendants();
750 for (const auto& sprite : descendants)
751 {
752 ssize_t currentIndex = sprite->getAtlasIndex();
753 AXASSERT(prev == currentIndex - 1, "Child order failed");
754 ////----AXLOGD("descendant {:#x} - atlasIndex:{}", child, currentIndex);
755 prev = currentIndex;
756 }
757}
758
759std::string SpriteBatchNodeReorder::title() const
760{

Callers

nothing calls this directly

Calls 7

createFunction · 0.85
pushBackMethod · 0.80
RectClass · 0.50
getTextureMethod · 0.45
addChildMethod · 0.45
reorderChildMethod · 0.45
atMethod · 0.45

Tested by

no test coverage detected