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

Method insertQuadFromSprite

core/2d/SpriteBatchNode.cpp:711–734  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

709// implementation SpriteSheet (TMXTiledMapExtension)
710
711void SpriteBatchNode::insertQuadFromSprite(Sprite* sprite, ssize_t index)
712{
713 AXASSERT(sprite != nullptr, "Argument must be non-nullptr");
714 AXASSERT(dynamic_cast<Sprite*>(sprite), "CCSpriteBatchNode only supports Sprites as children");
715
716 // make needed room
717 while (index >= _textureAtlas->getCapacity() || _textureAtlas->getCapacity() == _textureAtlas->getTotalQuads())
718 {
719 this->increaseAtlasCapacity();
720 }
721 //
722 // update the quad directly. Don't add the sprite to the scene graph
723 //
724 sprite->setBatchNode(this);
725 sprite->setAtlasIndex(static_cast<unsigned int>(index));
726
727 auto&& quad = sprite->getQuad();
728 _textureAtlas->insertQuad(quad, index);
729
730 // FIXME:: updateTransform will update the textureAtlas too, using updateQuad.
731 // FIXME:: so, it should be AFTER the insertQuad
732 sprite->setDirty(true);
733 sprite->updateTransform();
734}
735
736void SpriteBatchNode::updateQuadFromSprite(Sprite* sprite, ssize_t index)
737{

Callers 1

updateQuadsMethod · 0.80

Calls 7

increaseAtlasCapacityMethod · 0.95
getTotalQuadsMethod · 0.80
insertQuadMethod · 0.80
setDirtyMethod · 0.80
getCapacityMethod · 0.45
setBatchNodeMethod · 0.45
updateTransformMethod · 0.45

Tested by

no test coverage detected