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

Method reparentSprite

tests/cpp-tests/Source/SpriteTest/SpriteTest.cpp:2600–2628  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2598}
2599
2600void SpriteHybrid::reparentSprite(float dt)
2601{
2602 auto p1 = getChildByTag(kTagNode);
2603 auto p2 = getChildByTag(kTagSpriteBatchNode);
2604
2605 Vector<Node*> retArray(250);
2606
2607 if (_usingSpriteBatchNode)
2608 std::swap(p1, p2);
2609
2610 ////----AXLOGD("New parent is: {:#x}", p2);
2611
2612 auto& p1Children = p1->getChildren();
2613 for (const auto& node : p1Children)
2614 {
2615 retArray.pushBack(node);
2616 }
2617
2618 int i = 0;
2619 p1->removeAllChildrenWithCleanup(false);
2620
2621 for (const auto& node : retArray)
2622 {
2623 p2->addChild(node, i, i);
2624 i++;
2625 }
2626
2627 _usingSpriteBatchNode = !_usingSpriteBatchNode;
2628}
2629
2630void SpriteHybrid::onExit()
2631{

Callers

nothing calls this directly

Calls 5

getChildByTagFunction · 0.85
pushBackMethod · 0.80
swapFunction · 0.50
addChildMethod · 0.45

Tested by

no test coverage detected