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

Method addChild

core/2d/Sprite.cpp:1120–1142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1118// MARK: visit, draw, transform
1119
1120void Sprite::addChild(Node* child, int zOrder, int tag)
1121{
1122 AXASSERT(child != nullptr, "Argument must be non-nullptr");
1123 if (child == nullptr)
1124 return;
1125
1126 if (_renderMode == RenderMode::QUAD_BATCHNODE)
1127 {
1128 Sprite* childSprite = dynamic_cast<Sprite*>(child);
1129 AXASSERT(childSprite, "CCSprite only supports Sprites as children when using SpriteBatchNode");
1130 AXASSERT(childSprite->getTexture() == _textureAtlas->getTexture(),
1131 "childSprite's texture name should be equal to _textureAtlas's texture name!");
1132 // put it in descendants array of batch node
1133 _batchNode->appendChild(childSprite);
1134
1135 if (!_reorderChildDirty)
1136 {
1137 setReorderChildDirtyRecursively();
1138 }
1139 }
1140 // CCNode already sets isReorderChildDirty_ so this needs to be after batchNode check
1141 Node::addChild(child, zOrder, tag);
1142}
1143
1144void Sprite::addChild(Node* child, int zOrder, std::string_view name)
1145{

Callers

nothing calls this directly

Calls 2

appendChildMethod · 0.80
getTextureMethod · 0.45

Tested by

no test coverage detected