Example #1
0
// override visit
// don't call visit on it's children
void SpriteBatchNode::visit(void)
{
    CC_PROFILER_START_CATEGORY(kProfilerCategoryBatchSprite, "CCSpriteBatchNode - visit");

    // CAREFUL:
    // This visit is almost identical to CocosNode#visit
    // with the exception that it doesn't call visit on it's children
    //
    // The alternative is to have a void Sprite#visit, but
    // although this is less maintainable, is faster
    //
    if (! _visible)
    {
        return;
    }

    kmGLPushMatrix();

    sortAllChildren();
    transform();

    draw();

    kmGLPopMatrix();
    setOrderOfArrival(0);

    CC_PROFILER_STOP_CATEGORY(kProfilerCategoryBatchSprite, "CCSpriteBatchNode - visit");
}
Example #2
0
void Label::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated)
{
    if (! _visible || _originalUTF8String.empty())
    {
        return;
    }
    if (_fontDirty)
    {
        updateFont();
    }
    if (_contentDirty)
    {
        updateContent();
    }

    bool dirty = parentTransformUpdated || _transformUpdated;

    if (_shadowEnabled && _shadowBlurRadius <= 0 && (_shadowDirty || dirty))
    {
        _position.x += _shadowOffset.width;
        _position.y += _shadowOffset.height;
        _transformDirty = _inverseDirty = true;

        _shadowTransform = transform(parentTransform);

        _position.x -= _shadowOffset.width;
        _position.y -= _shadowOffset.height;
        _transformDirty = _inverseDirty = true;

        _shadowDirty = false;
    }

    if(dirty)
    {
        _modelViewTransform = transform(parentTransform);
    }
    _transformUpdated = false;

    // IMPORTANT:
    // To ease the migration to v3.0, we still support the kmGL stack,
    // but it is deprecated and your code should not rely on it
    kmGLPushMatrix();
    kmGLLoadMatrix(&_modelViewTransform);

    if (_textSprite)
    {
        drawTextSprite(renderer,dirty);
    }
    else
    {
        draw(renderer, _modelViewTransform, dirty);
    }

    kmGLPopMatrix();
    
    setOrderOfArrival(0);
}
Example #3
0
void Label::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
{
    if (! _visible || _originalUTF8String.empty())
    {
        return;
    }
    if (_systemFontDirty)
    {
        updateFont();
    }
    if (_contentDirty)
    {
        updateContent();
    }

    uint32_t flags = processParentFlags(parentTransform, parentFlags);

    if (_shadowEnabled && _shadowBlurRadius <= 0 && (_shadowDirty || (flags & FLAGS_DIRTY_MASK)))
    {
        _position.x += _shadowOffset.width;
        _position.y += _shadowOffset.height;
        _transformDirty = _inverseDirty = true;

        _shadowTransform = transform(parentTransform);

        _position.x -= _shadowOffset.width;
        _position.y -= _shadowOffset.height;
        _transformDirty = _inverseDirty = true;

        _shadowDirty = false;
    }

    // IMPORTANT:
    // To ease the migration to v3.0, we still support the Mat4 stack,
    // but it is deprecated and your code should not rely on it
    Director* director = Director::getInstance();
    CCASSERT(nullptr != director, "Director is null when seting matrix stack");
    
    director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
    director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewTransform);
    

    if (_textSprite)
    {
        drawTextSprite(renderer, flags);
    }
    else
    {
        draw(renderer, _modelViewTransform, flags);
    }

    director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
    
    setOrderOfArrival(0);
}
Example #4
0
void Label::visit()
{
    if (! _visible)
    {
        return;
    }
    
    kmGLPushMatrix();

    transform();
    draw();

    kmGLPopMatrix();

    setOrderOfArrival(0);
}
void IsometryNode::visit()
{
    //setPosition(CCPointMake(0, 500));
    //CCNode::visit();
    //Stats();
    if(getShaderProgram() == nullptr)
    {
        setShaderProgram(CCShaderCache::sharedShaderCache()->programForKey(kCCShader_PositionTextureColor));
    }
    
    CC_PROFILER_START_CATEGORY(kCCProfilerCategoryBatchSprite, "CCSpriteBatchNode - visit");
    
    // CAREFUL:
    // This visit is almost identical to CocosNode#visit
    // with the exception that it doesn't call visit on it's children
    //
    // The alternative is to have a void CCSprite#visit, but
    // although this is less maintainable, is faster
    //
    if (! m_bVisible)
    {
        return;
    }
    
    kmGLPushMatrix();
    
    if (m_pGrid && m_pGrid->isActive())
    {
        m_pGrid->beforeDraw();
        transformAncestors();
    }
    
    sortAllChildren();
    transform();

    draw();
    
    if (m_pGrid && m_pGrid->isActive())
    {
        m_pGrid->afterDraw(this);
    }
    
    kmGLPopMatrix();
    setOrderOfArrival(0);
    
    CC_PROFILER_STOP_CATEGORY(kCCProfilerCategoryBatchSprite, "CCSpriteBatchNode - visit");
}
Example #6
0
void CABatchView::visit(void)
{
    CC_PROFILER_START_CATEGORY(kCCProfilerCategoryBatchSprite, "CABatchView - visit");

    CC_RETURN_IF(!m_bVisible);
    
    kmGLPushMatrix();
    sortAllSubview();
    transform();

    draw();

    kmGLPopMatrix();
    setOrderOfArrival(0);

    CC_PROFILER_STOP_CATEGORY(kCCProfilerCategoryBatchSprite, "CABatchView - visit");

}
Example #7
0
void Label::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated)
{
    if (! _visible || _originalUTF8String.empty())
    {
        return;
    }
    if (_contentDirty)
    {
        updateContent();
    }

    if (! _textSprite && _currLabelEffect == LabelEffect::SHADOW && _shadowBlurRadius <= 0)
    {
        _parentTransform = parentTransform;
        draw(renderer, _modelViewTransform, true);
    }
    else
    {
        bool dirty = parentTransformUpdated || _transformUpdated;
        
        if(dirty)
            _modelViewTransform = transform(parentTransform);
        _transformUpdated = false;

        // IMPORTANT:
        // To ease the migration to v3.0, we still support the kmGL stack,
        // but it is deprecated and your code should not rely on it
        kmGLPushMatrix();
        kmGLLoadMatrix(&_modelViewTransform);

        if (_textSprite)
        {
            _textSprite->visit();
        }
        else
        {
            draw(renderer, _modelViewTransform, dirty);
        }

        kmGLPopMatrix();
    }
    
    setOrderOfArrival(0);
}
// override visit
// don't call visit on it's children
// 是基类CCNode虚函数,是每帧会被调用到的函数。
void CCSpriteBatchNode::visit(void)
{
    CC_PROFILER_START_CATEGORY(kCCProfilerCategoryBatchSprite, "CCSpriteBatchNode - visit");

    // CAREFUL:
    // This visit is almost identical to CocosNode#visit
    // with the exception that it doesn't call visit on it's children
    //
    // The alternative is to have a void CCSprite#visit, but
    // although this is less maintainable, is faster
    //
	// 如果不显示,直接返回
    if (! m_bVisible)
    {
        return;
    }
	//矩阵压栈,保存渲染此结点前的所有OpenGL所需矩阵的值 
    kmGLPushMatrix();

    if (m_pGrid && m_pGrid->isActive())
    {
        m_pGrid->beforeDraw();
        transformAncestors();
    }

    sortAllChildren();
	//矩阵变量
    transform();
	//基类CCNode虚函数,用于实现当前CCNode的绘制
    draw();

    if (m_pGrid && m_pGrid->isActive())
    {
        m_pGrid->afterDraw(this);
    }
	//矩阵出栈。恢复渲染此结点前的所有OpenGL所需矩阵的值
    kmGLPopMatrix();
    setOrderOfArrival(0);

    CC_PROFILER_STOP_CATEGORY(kCCProfilerCategoryBatchSprite, "CCSpriteBatchNode - visit");

}
Example #9
0
void Label::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated)
{
    if (! _visible)
    {
        return;
    }
    
    bool dirty = parentTransformUpdated || _transformUpdated;
    if(dirty)
        _modelViewTransform = transform(parentTransform);
    _transformUpdated = false;

    // IMPORTANT:
    // To ease the migration to v3.0, we still support the kmGL stack,
    // but it is deprecated and your code should not rely on it
    kmGLPushMatrix();
    kmGLLoadMatrix(&_modelViewTransform);

    draw(renderer, _modelViewTransform, dirty);

    kmGLPopMatrix();

    setOrderOfArrival(0);
}