Example #1
0
SpriteBatchNode * SpriteBatchNode::addSpriteWithoutQuad(Sprite*child, int z, int aTag)
{
    CCASSERT( child != nullptr, "Argument must be non-nullptr");
    CCASSERT( dynamic_cast<Sprite*>(child), "CCSpriteBatchNode only supports Sprites as children");

    // quad index is Z
    child->setAtlasIndex(z);

    // FIXME:: optimize with a binary search
    auto it = _descendants.begin();
    for (; it != _descendants.end(); ++it)
    {
        if((*it)->getAtlasIndex() >= z)
            break;
    }

    _descendants.insert(it, child);

    // IMPORTANT: Call super, and not self. Avoid adding it to the texture atlas array
    Node::addChild(child, z, aTag);

    //#issue 1262 don't use lazy sorting, tiles are added as quads not as sprites, so sprites need to be added in order
    reorderBatch(false);

    return this;
}
Example #2
0
CABatchView * CABatchView::addViewWithoutQuad(CAView* view, unsigned int z, int aTag)
{
    CCAssert( view != NULL, "Argument must be non-NULL");

    view->setAtlasIndex(z);

    int i=0;
 
    CAVector<CAView*>::iterator itr;
    for (itr=m_obDescendants.begin(); itr!=m_obDescendants.end(); itr++)
    {
        CC_CONTINUE_IF((*itr)->getAtlasIndex() < z);
        ++i;
    }
    m_obDescendants.insert(i, view);

    CAView::insertSubview(view, z);
    view->setTag(aTag);
    reorderBatch(false);

    return this;
}