| 712 | //------------------------------------------------------------------ |
| 713 | |
| 714 | SpriteBatchNodeReorder::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 | |
| 759 | std::string SpriteBatchNodeReorder::title() const |
| 760 | { |
nothing calls this directly
no test coverage detected