Esempio n. 1
0
void CAIndicator::setOpacity(GLubyte opacity)
{
    CCScale9Sprite* indicator = dynamic_cast<CCScale9Sprite*>(m_pIndicator);
    if (indicator)
    {
        indicator->setOpacity(opacity);
        indicator->setColor(ccc3(opacity, opacity, opacity));
    }
}
Esempio n. 2
0
LayerChanToast::LayerChanToast(string message){
	vector<string> lstRegex;
	for( int i = 1; i <= 16; i++ ){
		lstRegex.push_back( CCString::createWithFormat("(%d)", i)->getCString() );
	}

	this->setAnchorPoint(ccp(0, 0));
	// text
	cocos2d::ui::RichText* label = cocos2d::ui::RichText::create();
	label->setAnchorPoint(ccp(0, 0));
	label->setPosition(ccp(0, HEIGHT_DESIGN / 3.5));

	vector<string> lstContents = mUtils::splitStringByListRegex(message, lstRegex);
	int wLabel = 0, hLabel = 0;
	for( int i = 0; i < lstContents.size(); i++ ){
		bool check = false;
		int j = 0;
		for( j = 0; j < lstRegex.size(); j++ )
			if( lstRegex.at(j) == lstContents.at(i) ){
				check = true;
				break;
			}
			if( check ){
				CCArmature *armature = CCArmature::create(CCString::createWithFormat("onion%d", 1)->getCString());
				armature->getAnimation()->playByIndex(j);
				cocos2d::ui::RichElementCustomNode* recustom = cocos2d::ui::RichElementCustomNode::create(1, ccWHITE, 255, armature);
				label->pushBackElement(recustom);
				wLabel += 50;
				hLabel = 55;
			}else{
				CCLabelTTF *l = CCLabelTTF::create(lstContents.at(i).c_str(), "Arial", 16);
				l->setColor(ccc3(204, 16, 85));
				cocos2d::ui::RichElementText* re1 = cocos2d::ui::RichElementText::create(1, ccWHITE, 255, lstContents.at(i).c_str(), "Arial", 16);
				label->pushBackElement(re1);
				wLabel += l->getContentSize().width;
				hLabel = hLabel > 50 ? 55 : l->getContentSize().height;
			}
	}
	this->addChild(label, 1, 0);

	CCSize sizeDesign = CCSize(169, 30);
	CCSpriteBatchNode *batchNode = CCSpriteBatchNode::create("chats/framechat_a.png");
	CCScale9Sprite *blocks = CCScale9Sprite::create();
	blocks ->updateWithBatchNode(batchNode , CCRect(0, 0, sizeDesign.width, sizeDesign.height), false, CCRect(10, 10, sizeDesign.width - 20, sizeDesign.height - 20));

	CCSize size = CCSizeMake(wLabel + 10, hLabel + 5);
	blocks ->setContentSize(size);
	blocks->setAnchorPoint(ccp(0.5, 0.5));
	blocks->setPosition(ccp(label->getPositionX() + wLabel / 2, label->getPositionY() + hLabel / 2));

	blocks->setColor(ccc3(84, 81, 69));
	blocks->setOpacity(200);
	this->setPosition(ccp((WIDTH_DESIGN - size.width) / 2, 100));
	// add
	this->addChild(blocks);
}
Esempio n. 3
0
void CAButton::onEnterTransitionDidFinish()
{
    CAView::onEnterTransitionDidFinish();
    
    if (this->CAControl::getBackGroundView() == NULL)
    {
        this->setBackGroundDefault();
    }
    
    if (this->getHighlightedBackGroundView() == NULL)
    {
        if (CCScale9Sprite* bg = dynamic_cast<CCScale9Sprite*>(this->CAControl::getBackGroundView()))
        {
            CCScale9Sprite* bgHighLighted = CCScale9Sprite::createWithImage(bg->getImage());
            bgHighLighted->setPreferredSize(bg->getPreferredSize());
            bgHighLighted->setColor(ccc3(127, 127, 127));
            this->setBackGround(CAControlStateHighlighted, bgHighLighted);
        }
        else if (CAImageView* bg = dynamic_cast<CAImageView*>(this->CAControl::getBackGroundView()))
        {
            CAImageView* bgHighLighted = CAImageView::createWithImage(bg->getImage());
            bgHighLighted->setBounds(bg->getBounds());
            bgHighLighted->setColor(ccc3(127, 127, 127));
            this->setBackGround(CAControlStateHighlighted, bgHighLighted);
        }
        else if (CAView* bg = dynamic_cast<CAView*>(this->CAControl::getBackGroundView()))
        {
            CAView* bgHighLighted = CAView::createWithFrame(bg->getFrame());
            bgHighLighted->setColor(ccc3(bg->getColor().r/2, bg->getColor().g/2, bg->getColor().b/2));
            this->setBackGround(CAControlStateHighlighted, bgHighLighted);
        }
    }
    
    this->updateWithPoint();
    this->setControlStateNormal();
}