Пример #1
0
// override visit.
// Don't call visit on it's children
void CCParticleBatchNode::visit()
{
    // CAREFUL:
    // This visit is almost identical to CCNode#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();
    }

    transform();

    draw();

    if ( m_pGrid && m_pGrid->isActive())
    {
        m_pGrid->afterDraw(this);
    }

    kmGLPopMatrix();
}
Пример #2
0
void CCRenderTexture::visit()
{
    // override visit.
	// Don't call visit on its children
    if (!m_bVisible)
    {
        return;
    }
	
	kmGLPushMatrix();
	
    if (m_pGrid && m_pGrid->isActive())
    {
        m_pGrid->beforeDraw();
        transformAncestors();
    }
    
    transform();
    m_pSprite->visit();
    draw();
	
    if (m_pGrid && m_pGrid->isActive())
    {
        m_pGrid->afterDraw(this);
    }
	
	kmGLPopMatrix();

    m_uOrderOfArrival = 0;
}
Пример #3
0
void wySpriteBatchNode::visit() {
	if(!m_visible)
		return;

	// should push matrix to avoid disturb current matrix
	glPushMatrix();

	// if grid is set, prepare grid
	if(m_grid != NULL && m_grid->isActive()) {
		m_grid->beforeDraw();
		transformAncestors();
	}

	// transform for myself
	transform();

	// check clip
	if(m_hasClip)
		doClip();

	// draw self
	draw();

	// restore
	if(m_hasClip)
		glDisable(GL_SCISSOR_TEST);

	// if grid is set, end grid
	if(m_grid != NULL && m_grid->isActive()) {
		m_grid->afterDraw(this);
	}

	// pop matrix
	glPopMatrix(); 
}
Пример #4
0
void RenderTexture::visit()
{
    // override visit.
	// Don't call visit on its children
    if (!_visible)
    {
        return;
    }
	
	kmGLPushMatrix();
	
    if (_grid && _grid->isActive())
    {
        _grid->beforeDraw();
        transformAncestors();
    }
    
    transform();
    _sprite->visit();
    draw();
	updateEventPriorityIndex();
    
    if (_grid && _grid->isActive())
    {
        _grid->afterDraw(this);
    }
	
	kmGLPopMatrix();

    _orderOfArrival = 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");
}
Пример #6
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");

}
Пример #7
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();

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

    sortAllChildren();
    transform();

    draw();

    if (_grid && _grid->isActive())
    {
        _grid->afterDraw(this);
    }

    kmGLPopMatrix();
    setOrderOfArrival(0);

    CC_PROFILER_STOP_CATEGORY(kProfilerCategoryBatchSprite, "CCSpriteBatchNode - visit");
}
Пример #8
0
	virtual void visit() {
		/*
		 * Here we do optimization in drawing scrollable children,
		 * child whose rect is outside of wyScrollableLayer is skipped
		 * to improve frame rate
		 */

		// if not visible
		if(!m_visible)
			return;

		// should push matrix to avoid disturb current matrix
		glPushMatrix();

		// if grid is set, prepare grid
		if(m_grid != NULL && m_grid->isActive()) {
			m_grid->beforeDraw();
			transformAncestors();
		}

		// transform for myself
		transform();

		// check clip
		if(m_hasClip)
			doClip();

		// parent is scrollable layer
		wyScrollableLayer* sl = (wyScrollableLayer*)m_parent;

		// parent size
		float pW = m_parent->getWidth();
		float pH = m_parent->getHeight();

		// draw children whose z order is less than zero
		for(int i = 0; i < m_children->num; i++) {
			wyNode* n = (wyNode*)wyArrayGet(m_children, i);
			if(n->getZOrder() < 0) {
				// get child bound relative to scrollable layer
				float w = n->getWidth();
				float h = n->getHeight();
				float x = n->isRelativeAnchorPoint() ? (n->getPositionX() - w * n->getAnchorX()) : n->getPositionX();
				float y = n->isRelativeAnchorPoint() ? (n->getPositionY() - h * n->getAnchorY()) : n->getPositionY();
				x += m_positionX;
				y += m_positionY;

				// check bound, if intersected, visit this child
				if(x + w > 0 && pW > x && y + h > 0 && pH > y) {
					// set flag so it will be notified when it is invisible
					wyUserData& ud = n->getUserData();
					ud.b = false;

					// visit it
					n->visit();
				} else {
					wyUserData& ud = n->getUserData();
					if(!ud.b) {
						sl->invokeOnScrollableChildNotVisible(n);
						ud.b = true;
					}
				}
			} else
				break;
		}

		// draw self
		draw();

		// draw children whose z order is larger than zero
		for(int i = 0; i < m_children->num; i++) {
			wyNode* n = (wyNode*)wyArrayGet(m_children, i);
			if(n->getZOrder() >= 0) {
				// get child bound relative to scrollable layer
				float w = n->getWidth();
				float h = n->getHeight();
				float x = n->isRelativeAnchorPoint() ? (n->getPositionX() - w * n->getAnchorX()) : n->getPositionX();
				float y = n->isRelativeAnchorPoint() ? (n->getPositionY() - h * n->getAnchorY()) : n->getPositionY();
				x += m_positionX;
				y += m_positionY;

				// check bound, if intersected, visit this child
				if(x + w > 0 && pW > x && y + h > 0 && pH > y) {
					// set flag so it will be notified when it is invisible
					wyUserData& ud = n->getUserData();
					ud.b = false;

					// visit it
					n->visit();
				} else {
					wyUserData& ud = n->getUserData();
					if(!ud.b) {
						sl->invokeOnScrollableChildNotVisible(n);
						ud.b = true;
					}
				}
			}
		}

		// restore
		if(m_hasClip)
			glDisable(GL_SCISSOR_TEST);

		// if grid is set, end grid
		if(m_grid != NULL && m_grid->isActive()) {
			m_grid->afterDraw(this);
		}

		// pop matrix
		glPopMatrix();
	}