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

Method removeSpriteFromAtlas

core/2d/SpriteBatchNode.cpp:636–669  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

634}
635
636void SpriteBatchNode::removeSpriteFromAtlas(Sprite* sprite)
637{
638 // remove from TextureAtlas
639 _textureAtlas->removeQuadAtIndex(sprite->getAtlasIndex());
640
641 // Cleanup sprite. It might be reused (issue #569)
642 sprite->setBatchNode(nullptr);
643
644 auto it = std::find(_descendants.begin(), _descendants.end(), sprite);
645 if (it != _descendants.end())
646 {
647 auto next = std::next(it);
648
649 Sprite* spr = nullptr;
650 for (auto nextEnd = _descendants.end(); next != nextEnd; ++next)
651 {
652 spr = *next;
653 spr->setAtlasIndex(spr->getAtlasIndex() - 1);
654 }
655
656 _descendants.erase(it);
657 }
658
659 // remove children recursively
660 auto& children = sprite->getChildren();
661 for (const auto& obj : children)
662 {
663 Sprite* child = static_cast<Sprite*>(obj);
664 if (child)
665 {
666 removeSpriteFromAtlas(child);
667 }
668 }
669}
670
671void SpriteBatchNode::updateBlendFunc()
672{

Callers 2

removeChildMethod · 0.80

Calls 7

removeQuadAtIndexMethod · 0.80
findFunction · 0.50
nextFunction · 0.50
setBatchNodeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected