コード例 #1
0
void UIWidget::setOpacity(int opacity)
{
    CCRGBAProtocol* rgbap = DYNAMIC_CAST_CCRGBAPROTOCOL;
    if (rgbap)
    {
        rgbap->setOpacity(opacity);
    }
}
コード例 #2
0
ファイル: Layout.cpp プロジェクト: boruis/cocos2dx-classical
void Layout::updateBackGroundImageOpacity()
{
    CCRGBAProtocol* rgba = dynamic_cast<CCRGBAProtocol*>(_backGroundImage);
    if (rgba)
    {
        rgba->setOpacity(_backGroundImageOpacity);
    }
}
コード例 #3
0
//--------------------------------------------------------------------
// 递归渐隐
void FKCW_Action_TreeFadeOut::FadeOutRecursively( CCNode* p_pRoot, float p_fTime )
{
	CCRGBAProtocol* p = dynamic_cast<CCRGBAProtocol*>(p_pRoot);
	if(p)
	{
		p->setOpacity((GLubyte)(255 * (1 - p_fTime)));
	}

	CCArray* children = p_pRoot->getChildren();
	int cc = p_pRoot->getChildrenCount();
	for(int i = 0; i < cc; i++)
	{
		CCNode* child = (CCNode*)children->objectAtIndex(i);
		if(!m_vecExcludeList.containsObject(child)) 
		{
			FadeOutRecursively(child, p_fTime);
		} 
		else if(!m_bIsRecursivelyExclude) 
		{
			FadeOutRecursively(child, p_fTime);
		}
	}

	// 检查UI
	Widget* w = dynamic_cast<Widget*>(p_pRoot);
	if(w) 
	{
		if(w->getVirtualRenderer()) 
		{
			CCRGBAProtocol* p = dynamic_cast<CCRGBAProtocol*>(w->getVirtualRenderer());
			if(p) 
			{
				p->setOpacity((GLubyte)(255 * (1 - p_fTime)));
			}
		}

		CCArray* children = w->getNodes();
		int cc = children->count();
		for(int i = 0; i < cc; i++) 
		{
			CCNode* child = (CCNode*)children->objectAtIndex(i);
			FadeOutRecursively(child, p_fTime);
		}
	}
}
コード例 #4
0
ファイル: CCActionInterval.cpp プロジェクト: noriter/nit
void CCFadeIn::update(ccTime time)
{
	CCRGBAProtocol *pRGBAProtocol = m_pTarget->convertToRGBAProtocol();
	if (pRGBAProtocol)
	{
        pRGBAProtocol->setOpacity((GLubyte)(255 * time));
	}
	/*m_pTarget->setOpacity((GLubyte)(255 * time));*/
}
コード例 #5
0
void CCFadeOut::update(ccTime time)
{
	CCRGBAProtocol *pRGBAProtocol = dynamic_cast<CCRGBAProtocol*>(m_pTarget);
	if (pRGBAProtocol)
	{
		pRGBAProtocol->setOpacity(CCubyte(255 * (1 - time)));
	}
	/*m_pTarget->setOpacity(CCubyte(255 * (1 - time)));*/	
}
コード例 #6
0
void CCFadeTo::update(ccTime time)
{
	CCRGBAProtocol *pRGBAProtocol = dynamic_cast<CCRGBAProtocol*>(m_pTarget);
	if (pRGBAProtocol)
	{
		pRGBAProtocol->setOpacity((CCubyte)(m_fromOpacity + (m_toOpacity - m_fromOpacity) * time));
	}
	/*m_pTarget->setOpacity((CCubyte)(m_fromOpacity + (m_toOpacity - m_fromOpacity) * time));*/
}
コード例 #7
0
void CCFadeTo::update(cocos2d::ccTime time)
{
	CCRGBAProtocol *pRGBAProtocol = m_pTarget->convertToRGBAProtocol();
	if (pRGBAProtocol)
	{
		pRGBAProtocol->setOpacity((GLubyte)(m_fromOpacity + (m_toOpacity - m_fromOpacity) * time));
	}
	/*m_pTarget->setOpacity((GLubyte)(m_fromOpacity + (m_toOpacity - m_fromOpacity) * time));*/
}
コード例 #8
0
void CCFadeOut::update(cocos2d::ccTime time)
{
	CCRGBAProtocol *pRGBAProtocol = m_pTarget->convertToRGBAProtocol();
	if (pRGBAProtocol)
	{
		pRGBAProtocol->setOpacity(GLubyte(255 * (1 - time)));
	}
	/*m_pTarget->setOpacity(GLubyte(255 * (1 - time)));*/	
}
コード例 #9
0
void CCFadeIn::update(ccTime time)
{
	CCRGBAProtocol *pRGBAProtocol = dynamic_cast<CCRGBAProtocol*>(m_pTarget);
	if (pRGBAProtocol)
	{
        pRGBAProtocol->setOpacity((GLubyte)(255 * time));
	}
	/*m_pTarget->setOpacity((GLubyte)(255 * time));*/
}
コード例 #10
0
ファイル: GUINodeRGBA.cpp プロジェクト: Michael-Z/SouShen
void GUINodeRGBA::addChild(cocos2d::CCNode *child)
{
    CCNode::addChild(child);
    CCRGBAProtocol *item = dynamic_cast<CCRGBAProtocol*>(child);
    if (item)
    {
        item->setColor(this->getColor());
        item->setOpacity(this->getOpacity());
    }
}
コード例 #11
0
ファイル: UILayout.cpp プロジェクト: ShortTailLab/cocos2d-x
void UILayout::setOpacity(int opacity)
{
    UIWidget::setOpacity(opacity);
    if (m_pBackGroundImage)
    {
        CCRGBAProtocol* rgbap = dynamic_cast<CCRGBAProtocol*>(m_pBackGroundImage);
        if (rgbap)
        {
            rgbap->setOpacity(opacity);
        }
    }
}
コード例 #12
0
void CCSpecialSprite::setOpacity(GLubyte opacity)
{
	CCSprite::setOpacity(opacity);
    
    Vector<CCNode *>::const_iterator beg = _children.begin();
    Vector<CCNode *>::const_iterator end = _children.end();
    for (; beg != end; ++beg)
    {
        CCRGBAProtocol * rgba = dynamic_cast<CCRGBAProtocol *>(*beg);
        if (rgba != NULL)
            rgba->setOpacity(opacity);
    }
}
コード例 #13
0
ファイル: CCUtils.cpp プロジェクト: live17909/cocos2dx-better
void CCUtils::setTreeOpacity(CCNode* n, int o) {
	// self
	CCRGBAProtocol* p = dynamic_cast<CCRGBAProtocol*>(n);
	if(p) {
		p->setOpacity((GLubyte)o);
	}
	
	// children
	CCArray* children = n->getChildren();
	CCObject* pObj = NULL;
	CCARRAY_FOREACH(children, pObj) {
		setTreeOpacity((CCNode*)pObj, o);
	}
コード例 #14
0
void CCSpecialSprite::addChild(CCNode *pChild, int zOrder, int tag)
{
	CCSprite::addChild(pChild, zOrder, tag);

	setTexture(((CCSprite*)pChild)->getTexture());
    
	CCRGBAProtocol * rgba = dynamic_cast<CCRGBAProtocol *>(pChild);
	if (rgba != NULL)
	{
		rgba->setColor(this->getColor());
		rgba->setOpacity(this->getOpacity());
	}
}
コード例 #15
0
void CCControlButton::setOpacity(GLubyte opacity)
{
    m_cOpacity = opacity;

    CCObject* child;
    CCArray* children=getChildren();
    CCARRAY_FOREACH(children, child)
    {
        CCRGBAProtocol* pNode = dynamic_cast<CCRGBAProtocol*>(child);
        if (pNode)
        {
            pNode->setOpacity(opacity);
        }
    }
コード例 #16
0
void CCTreeFadeIn::fadeInRecursively(CCNode* n, float time) {
    CCArray* children = n->getChildren();
    int cc = n->getChildrenCount();
    for(int i = 0; i < cc; i++) {
        CCNode* child = (CCNode*)children->objectAtIndex(i);
		if(!m_excludeList.containsObject(child)) {
			CCRGBAProtocol* p = dynamic_cast<CCRGBAProtocol*>(child);
			if(p) {
				p->setOpacity((GLubyte)(255 * time));
			}
		}
        
        fadeInRecursively(child, time);
    }
}
コード例 #17
0
void Crystal820Layer::updateColor(void)
{
	CCLayerColor::updateColor();
	if(m_pChildren && m_pChildren->count() > 0)
	{
        CCObject* child;
        CCARRAY_FOREACH(m_pChildren, child)
        {
            CCNode* pNode = (CCNode*) child;
			CCRGBAProtocol *pRGBAProtocol = dynamic_cast<CCRGBAProtocol*>(pNode);
			if (pRGBAProtocol)
			{
				pRGBAProtocol->setOpacity(m_cOpacity);
			}
		}
コード例 #18
0
	void CCLabelBMFont::setOpacity(GLubyte var)
	{
		m_cOpacity = var;

		if (m_pChildren && m_pChildren->count() != 0)
		{
			NSMutableArray<CCNode*>::NSMutableArrayIterator it;
			for(it = m_pChildren->begin(); it != m_pChildren->end(); ++it)
			{
				CCRGBAProtocol *pRGBAProtocol = (*it)->convertToRGBAProtocol();
				if (pRGBAProtocol)
				{
                    pRGBAProtocol->setOpacity(m_cOpacity);
				}
			}
		}
	}
コード例 #19
0
void RichText::formatText()
{
    if (_formatTextDirty)
    {
        _elementRenderersContainer->removeAllChildren();
        _elementRenders.clear();
        if (_ignoreSize)
        {
            addNewLine();
            for (unsigned int i=0; i<_richElements->count(); i++)
            {
                RichElement* element = static_cast<RichElement*>(_richElements->objectAtIndex(i));
                CCNode* elementRenderer = NULL;
                switch (element->_type)
                {
                    case RICH_TEXT:
                    {
                        RichElementText* elmtText = static_cast<RichElementText*>(element);
                        elementRenderer = CCLabelTTF::create(elmtText->_text.c_str(), elmtText->_fontName.c_str(), elmtText->_fontSize);
                        break;
                    }
                    case RICH_IMAGE:
                    {
                        RichElementImage* elmtImage = static_cast<RichElementImage*>(element);
                        elementRenderer = CCSprite::create(elmtImage->_filePath.c_str());
                        break;
                    }
                    case RICH_CUSTOM:
                    {
                        RichElementCustomNode* elmtCustom = static_cast<RichElementCustomNode*>(element);
                        elementRenderer = elmtCustom->_customNode;
                        break;
                    }
                    default:
                        break;
                }
                CCRGBAProtocol* colorRenderer = dynamic_cast<CCRGBAProtocol*>(elementRenderer);
                colorRenderer->setColor(element->_color);
                colorRenderer->setOpacity(element->_opacity);
                pushToContainer(elementRenderer);
            }
        }
        else
        {
            addNewLine();
            for (unsigned int i=0; i<_richElements->count(); i++)
            {
                
                RichElement* element = static_cast<RichElement*>(_richElements->objectAtIndex(i));
                switch (element->_type)
                {
                    case RICH_TEXT:
                    {
                        RichElementText* elmtText = static_cast<RichElementText*>(element);
                        handleTextRenderer(elmtText->_text.c_str(), elmtText->_fontName.c_str(), elmtText->_fontSize, elmtText->_color, elmtText->_opacity);
                        break;
                    }
                    case RICH_IMAGE:
                    {
                        RichElementImage* elmtImage = static_cast<RichElementImage*>(element);
                        handleImageRenderer(elmtImage->_filePath.c_str(), elmtImage->_color, elmtImage->_opacity);
                        break;
                    }
                    case RICH_CUSTOM:
                    {
                        RichElementCustomNode* elmtCustom = static_cast<RichElementCustomNode*>(element);
                        handleCustomRenderer(elmtCustom->_customNode);
                        break;
                    }
                    default:
                        break;
                }
            }
        }
        formarRenderers();
        _formatTextDirty = false;
    }
}
コード例 #20
0
void NodeReader::initNode(cocos2d::CCNode* node, const rapidjson::Value& json)
{
    float x             = DICTOOL->getFloatValue_json(json, X);
    float y             = DICTOOL->getFloatValue_json(json, Y);
    float scalex        = DICTOOL->getFloatValue_json(json, SCALE_X, 1);
    float scaley        = DICTOOL->getFloatValue_json(json, SCALE_Y, 1);
    float rotation      = DICTOOL->getFloatValue_json(json, ROTATION);
    float rotationSkewX = DICTOOL->getFloatValue_json(json, ROTATION_SKEW_X);
    float rotationSkewY = DICTOOL->getFloatValue_json(json, ROTATION_SKEW_X);
    float skewx         = DICTOOL->getFloatValue_json(json, SKEW_X);
    float skewy         = DICTOOL->getFloatValue_json(json, SKEW_Y);
    float anchorx       = DICTOOL->getFloatValue_json(json, ANCHOR_X, 0.5f);
    float anchory       = DICTOOL->getFloatValue_json(json, ANCHOR_Y, 0.5f);
    GLubyte alpha       = (GLubyte)DICTOOL->getIntValue_json(json, ALPHA, 255);
    GLubyte red         = (GLubyte)DICTOOL->getIntValue_json(json, RED, 255);
    GLubyte green       = (GLubyte)DICTOOL->getIntValue_json(json, GREEN, 255);
    GLubyte blue        = (GLubyte)DICTOOL->getIntValue_json(json, BLUE, 255);
    int zorder          = DICTOOL->getIntValue_json(json, ZORDER);
    int tag             = DICTOOL->getIntValue_json(json, TAG);
    int actionTag       = DICTOOL->getIntValue_json(json, ACTION_TAG);
    bool visible        = DICTOOL->getBooleanValue_json(json, VISIBLE);

    if(x != 0 || y != 0)
        node->setPosition(CCPoint(x, y));
    if(scalex != 1)
        node->setScaleX(scalex);
    if(scaley != 1)
        node->setScaleY(scaley);
    if (rotation != 0)
        node->setRotation(rotation);
    if(rotationSkewX != 0)
        node->setRotationX(rotationSkewX);
    if(rotationSkewY != 0)
        node->setRotationY(rotationSkewY);
    if(skewx != 0)
        node->setSkewX(skewx);
    if(skewy != 0)
        node->setSkewY(skewy);
    if(anchorx != 0.5f || anchory != 0.5f)
        node->setAnchorPoint(CCPoint(anchorx, anchory));
    if(zorder != 0)
        node->setZOrder(zorder);
    if(visible != true)
        node->setVisible(visible);

    CCRGBAProtocol *rgbaProtocaol = dynamic_cast<CCRGBAProtocol *>(node);
    if(rgbaProtocaol)
    {
        if(alpha != 255)
        {
            rgbaProtocaol->setOpacity(alpha); 
        }
        if(red != 255 || green != 255 || blue != 255)
        {
            rgbaProtocaol->setColor(ccc3(red, green, blue));
        }
    }

    node->setTag(tag);
	node->setUserObject(TimelineActionData::create(actionTag));
}