Exemplo n.º 1
0
void UIWidget::setColor(const Color3B &color)
{
    RGBAProtocol* rgbap = DYNAMIC_CAST_RGBAProtocol;
    if (rgbap)
    {
        rgbap->setColor(color);
    }
}
Exemplo n.º 2
0
void UIWidget::setCascadeOpacityEnabled(bool cascadeOpacityEnabled)
{
    RGBAProtocol* rgbap = DYNAMIC_CAST_RGBAProtocol;
    if (rgbap)
    {
        rgbap->setCascadeOpacityEnabled(cascadeOpacityEnabled);
    }
}
Exemplo n.º 3
0
void UIWidget::setOpacity(int opacity)
{
    RGBAProtocol* rgbap = DYNAMIC_CAST_RGBAProtocol;
    if (rgbap)
    {
        rgbap->setOpacity(opacity);
    }
}
Exemplo n.º 4
0
void FadeOut::update(float time)
{
    RGBAProtocol *pRGBAProtocol = dynamic_cast<RGBAProtocol*>(_target);
    if (pRGBAProtocol)
    {
        pRGBAProtocol->setOpacity(GLubyte(255 * (1 - time)));
    }
    /*_target->setOpacity(GLubyte(255 * (1 - time)));*/    
}
Exemplo n.º 5
0
bool UIWidget::isCascadeColorEnabled()
{
    RGBAProtocol* rgbap = DYNAMIC_CAST_RGBAProtocol;
    if (rgbap)
    {
        return rgbap->isCascadeColorEnabled();
    }
    return false;
}
Exemplo n.º 6
0
int UIWidget::getOpacity()
{
    RGBAProtocol* rgbap = DYNAMIC_CAST_RGBAProtocol;
    if (rgbap)
    {
        return rgbap->getOpacity();
    }
    return 255;
}
Exemplo n.º 7
0
const Color3B& UIWidget::getColor()
{
    RGBAProtocol* rgbap = DYNAMIC_CAST_RGBAProtocol;
    if (rgbap)
    {
        return rgbap->getColor();
    }
    return Color3B::WHITE;
}
Exemplo n.º 8
0
void FadeTo::update(float time)
{
    RGBAProtocol *pRGBAProtocol = dynamic_cast<RGBAProtocol*>(_target);
    if (pRGBAProtocol)
    {
        pRGBAProtocol->setOpacity((GLubyte)(_fromOpacity + (_toOpacity - _fromOpacity) * time));
    }
    /*_target->setOpacity((GLubyte)(_fromOpacity + (_toOpacity - _fromOpacity) * time));*/
}
Exemplo n.º 9
0
void TintBy::update(float time)
{
    RGBAProtocol *pRGBAProtocol = dynamic_cast<RGBAProtocol*>(_target);
    if (pRGBAProtocol)
    {
        pRGBAProtocol->setColor(Color3B((GLubyte)(_fromR + _deltaR * time),
            (GLubyte)(_fromG + _deltaG * time),
            (GLubyte)(_fromB + _deltaB * time)));
    }    
}
Exemplo n.º 10
0
void TintTo::update(float time)
{
    RGBAProtocol *pRGBAProtocol = dynamic_cast<RGBAProtocol*>(_target);
    if (pRGBAProtocol)
    {
        pRGBAProtocol->setColor(Color3B(GLubyte(_from.r + (_to.r - _from.r) * time), 
            (GLubyte)(_from.g + (_to.g - _from.g) * time),
            (GLubyte)(_from.b + (_to.b - _from.b) * time)));
    }    
}
Exemplo n.º 11
0
void TintTo::startWithTarget(Node *target)
{
    ActionInterval::startWithTarget(target);
    RGBAProtocol *pRGBAProtocol = dynamic_cast<RGBAProtocol*>(_target);
    if (pRGBAProtocol)
    {
        _from = pRGBAProtocol->getColor();
    }
    /*_from = target->getColor();*/
}
Exemplo n.º 12
0
void FadeTo::startWithTarget(Node *target)
{
    ActionInterval::startWithTarget(target);

    RGBAProtocol *pRGBAProtocol = dynamic_cast<RGBAProtocol*>(target);
    if (pRGBAProtocol)
    {
        _fromOpacity = pRGBAProtocol->getOpacity();
    }
    /*_fromOpacity = target->getOpacity();*/
}
Exemplo n.º 13
0
void TintBy::startWithTarget(Node *target)
{
    ActionInterval::startWithTarget(target);

    RGBAProtocol *pRGBAProtocol = dynamic_cast<RGBAProtocol*>(target);
    if (pRGBAProtocol)
    {
        Color3B color = pRGBAProtocol->getColor();
        _fromR = color.r;
        _fromG = color.g;
        _fromB = color.b;
    }    
}
Exemplo n.º 14
0
/** Override synthesized setOpacity to recurse items */
void LayerRGBA::setOpacity(GLubyte opacity)
{
	m_cDisplayedOpacity = m_cRealOpacity = opacity;
    
	if( m_bCascadeOpacityEnabled )
    {
		GLubyte parentOpacity = 255;
        RGBAProtocol *parent = dynamic_cast<RGBAProtocol*>(m_pParent);
        if (parent && parent->isCascadeOpacityEnabled())
        {
            parentOpacity = parent->getDisplayedOpacity();
        }
        updateDisplayedOpacity(parentOpacity);
	}
}
Exemplo n.º 15
0
void LayerRGBA::setColor(const Color3B& color)
{
	m_tDisplayedColor = m_tRealColor = color;
	
	if (m_bCascadeColorEnabled)
    {
		Color3B parentColor = Color3B::WHITE;
        RGBAProtocol* parent = dynamic_cast<RGBAProtocol*>(m_pParent);
		if (parent && parent->isCascadeColorEnabled())
        {
            parentColor = parent->getDisplayedColor();
        }

        updateDisplayedColor(parentColor);
	}
}
Exemplo n.º 16
0
void LayerRGBA::updateDisplayedOpacity(GLubyte parentOpacity)
{
	m_cDisplayedOpacity = m_cRealOpacity * parentOpacity/255.0;
    
    if (m_bCascadeOpacityEnabled)
    {
        Object *obj = NULL;
        CCARRAY_FOREACH(m_pChildren, obj)
        {
            RGBAProtocol *item = dynamic_cast<RGBAProtocol*>(obj);
            if (item)
            {
                item->updateDisplayedOpacity(m_cDisplayedOpacity);
            }
        }
    }
Exemplo n.º 17
0
bool UIWidget::init()
{
    m_children = CCArray::create();
    m_children->retain();
    initRenderer();
    m_pRenderer->retain();
    m_pRenderer->setZOrder(m_nWidgetZOrder);
    RGBAProtocol* renderRGBA = DYNAMIC_CAST_RGBAProtocol;
    if (renderRGBA)
    {
        renderRGBA->setCascadeColorEnabled(true);
        renderRGBA->setCascadeOpacityEnabled(true);
    }
    setBright(true);
    ignoreContentAdaptWithSize(true);
    return true;
}
bool ControlButton::initWithLabelAndBackgroundSprite(Node* node, Scale9Sprite* backgroundSprite)
{
    if (Control::init())
    {
        CCASSERT(node != NULL, "Label must not be nil.");
        LabelProtocol* label = dynamic_cast<LabelProtocol*>(node);
        RGBAProtocol* rgbaLabel = dynamic_cast<RGBAProtocol*>(node);
        CCASSERT(backgroundSprite != NULL, "Background sprite must not be nil.");
        CCASSERT(label != NULL || rgbaLabel!=NULL || backgroundSprite != NULL, "");
        
        _parentInited = true;

        // Initialize the button state tables
        this->setTitleDispatchTable(Dictionary::create());
        this->setTitleColorDispatchTable(Dictionary::create());
        this->setTitleLabelDispatchTable(Dictionary::create());
        this->setBackgroundSpriteDispatchTable(Dictionary::create());

        setTouchEnabled(true);
        _isPushed = false;
        _zoomOnTouchDown = true;

        _currentTitle=NULL;

        // Adjust the background image by default
        setAdjustBackgroundImage(true);
        setPreferredSize(Size::ZERO);
        // Zooming button by default
        _zoomOnTouchDown = true;
        
        // Set the default anchor point
        ignoreAnchorPointForPosition(false);
        setAnchorPoint(Point(0.5f, 0.5f));
        
        // Set the nodes
        setTitleLabel(node);
        setBackgroundSprite(backgroundSprite);

        // Set the default color and opacity
        setColor(Color3B(255.0f, 255.0f, 255.0f));
        setOpacity(255.0f);
        setOpacityModifyRGB(true);
        
        // Initialize the dispatch table
        
        String* tempString = String::create(label->getString());
        //tempString->autorelease();
        setTitleForState(tempString, Control::State::NORMAL);
        setTitleColorForState(rgbaLabel->getColor(), Control::State::NORMAL);
        setTitleLabelForState(node, Control::State::NORMAL);
        setBackgroundSpriteForState(backgroundSprite, Control::State::NORMAL);
        
        setLabelAnchorPoint(Point(0.5f, 0.5f));

        // Layout update
        needsLayout();

        return true;
    }
    //couldn't init the Control
    else
    {
        return false;
    }
}