void CC3Billboard::setBillboard( CCNode* aCCNode )
{
	if (aCCNode == m_pBillboard) 
		return;							// Don't do anything if it's the same 2D billboard...
										// ...otherwise it will be detached from scheduler.
	// Old 2D billboard
	if ( m_pBillboard )
	{
		m_pBillboard->onExit();			// Turn off running state and pause activity.
		m_pBillboard->cleanup();			// Detach billboard from scheduler and actions.
		m_pBillboard->release();
	}

	// New 2D billboard
	m_pBillboard = aCCNode;

	if ( m_pBillboard )
	{
		m_pBillboard->retain();
		m_pBillboard->setVisible( isVisible() );
	}
	
	// Retrieve the blend function from the 2D node and align this 3D node's material with it.
#pragma _NOTE_TODO( "Bad behavior here!" )
	CCBlendProtocol* pVal = dynamic_cast<CCBlendProtocol*>(aCCNode);
	if ( pVal )
		setBlendFunc( pVal->getBlendFunc() );

	normalizeBillboardScaleToDevice();

	if ( isRunning() )
		start2DBillboard();	// If running already, start scheduled activities on new billboard
}
void UIWidget::setBlendFunc(ccBlendFunc blendFunc)
{
    CCBlendProtocol * blendNode = DYNAMIC_CAST_CCBLENDPROTOCOL;
    if (blendNode)
    {
        blendNode->setBlendFunc(blendFunc);
    }
}
void CCSpecialSprite::setBlendFunc(const cocos2d::BlendFunc & blendFunc)
{
    CCSprite::setBlendFunc(blendFunc);
    
    Vector<CCNode *>::const_iterator beg = _children.begin();
    Vector<CCNode *>::const_iterator end = _children.end();
    for (; beg != end; ++beg)
    {
        CCBlendProtocol * blend = dynamic_cast<CCBlendProtocol *>(*beg);
        if (blend != NULL)
            blend->setBlendFunc(blendFunc);
    }
}