当前位置: 首页>>代码示例>>C++>>正文


C++ CCLayerColor::setColor方法代码示例

本文整理汇总了C++中CCLayerColor::setColor方法的典型用法代码示例。如果您正苦于以下问题:C++ CCLayerColor::setColor方法的具体用法?C++ CCLayerColor::setColor怎么用?C++ CCLayerColor::setColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCLayerColor的用法示例。


在下文中一共展示了CCLayerColor::setColor方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: show

void ShowTip::show(const char *str, cocos2d::CCPoint& point, float fontSize, float delayTime, bool displayBg)
{
    CCLabelTTF* ttfTip = CCLabelTTF::create(str, "宋体", fontSize);
    ttfTip->cocos2d::CCNode::setAnchorPoint(CCPoint(0, 0));
    
    CCSize size = ttfTip->getContentSize();
    CCLayerColor* bgColor = NULL;
    if (displayBg)
    {
        bgColor = CCLayerColor::create();
        bgColor->setColor(ccColor3B(ccc3(0, 0, 0)));
        bgColor->setAnchorPoint(CCPoint(0.5,0.5));
        bgColor->setPosition(CCPoint(point.x - size.width * 0.5, point.y - 40));
        bgColor->setContentSize(size);
        bgColor->addChild(ttfTip);
        this->addChild(bgColor);
        
        ttfTip->setFontFillColor(ccColor3B(ccc3(255, 255, 255)));
    }
    else
    {
        size = CCSize(0,0);
        ttfTip->setFontFillColor(ccColor3B(ccc3(0, 0, 0)));
        ttfTip->setPosition(CCPoint(point.x, point.y - 60));
        this->addChild(ttfTip);
    }
    
    
    CCAction*  moveTo  = CCMoveTo::create(delayTime, CCPoint(point.x - size.width * 0.5, point.y + 40));
    
    if ( displayBg && bgColor )
    {
        CCFadeIn* fadeIn  = CCFadeIn::create(delayTime * 0.25);
        CCScaleTo* scaleTo = CCScaleTo::create(delayTime * 0.5, 1);
        CCFadeOut* fadeOut = CCFadeOut::create(delayTime * 0.25);
        bgColor->runAction(CCSequence::create(fadeIn,scaleTo, fadeOut, NULL));
        bgColor->runAction(moveTo);
    }
    else
    {
        CCFadeIn* fadeIn  = CCFadeIn::create(delayTime * 0.5);
        CCFadeOut* fadeOut = CCFadeOut::create(delayTime * 0.5);
        ttfTip->runAction(CCSequence::create(fadeIn, fadeOut, NULL));
        ttfTip->runAction(moveTo);
    }
    
    scheduleOnce(schedule_selector(ShowTip::removeFromParent), delayTime);
}
开发者ID:Fruedy,项目名称:yangsj,代码行数:48,代码来源:ShowTip.cpp

示例2: createPauseLayer

void GameLayer::createPauseLayer() {
	Context *context = Context::sharedContext();
	CCSize s = CCDirector::sharedDirector()->getWinSize();
	/* 半透明层 */
	CCLayerColor* pauseLayer = CCLayerColor::create();
	pauseLayer->setContentSize(CCSizeMake(s.width, s.height));
	pauseLayer->setColor(ccc3(0, 0, 0));
	pauseLayer->setOpacity(150);
	CCMenu *menu = CCMenu::create();
//回到游戏
	CCMenuItemImage *resumebg = CCMenuItemImage::create(("btn_big.png"),
			("btn_big.png"));
	resumebg->setTarget(this, menu_selector(GameLayer::onResumeItem));
	CCMenuItemFont *resumetxt = CCMenuItemFont::create(LOCAL_RESOURCES->valueByKey("i18n_resume")->getCString());
	resumebg->setAnchorPoint(ccp(0.5, 0.5));
	resumebg->setPosition(ccpp(0, 0));
	resumetxt->setPosition(
			ccp(resumebg->getContentSize().width / 2,
					resumebg->getContentSize().height / 2));
	resumetxt->setAnchorPoint(ccp(0.5, 0.5));
	resumetxt->setColor(context->getFontColor());
	resumebg->addChild(resumetxt);
	menu->addChild(resumebg);

//回到菜单
	CCMenuItemImage *backbg = CCMenuItemImage::create(("btn_big.png"),
			("btn_big.png"));
	backbg->setTarget(this, menu_selector(GameLayer::onBackItem));
	CCMenuItemFont *backtxt = CCMenuItemFont::create(LOCAL_RESOURCES->valueByKey("i18n_back")->getCString());
	backbg->setAnchorPoint(ccp(0.5, 0.5));
	backbg->setPosition(ccpp(0, -0.12));
	backtxt->setPosition(
			ccp(backbg->getContentSize().width / 2,
					backbg->getContentSize().height / 2));
	backtxt->setAnchorPoint(ccp(0.5, 0.5));
	backtxt->setColor(context->getFontColor());
	backbg->addChild(backtxt);
	menu->addChild(backbg);

	pauseLayer->addChild(menu);
	CCDirector::sharedDirector()->getRunningScene()->addChild(pauseLayer, 0,
	TAG_LAYER_PAUSE);
}
开发者ID:beforeeight,项目名称:sort,代码行数:43,代码来源:GameScene.cpp

示例3:

//--------------------------------------------------------
// CShaderNodeScene
//--------------------------------------------------------
CShaderNodeScene::CShaderNodeScene()
{
	CCLayerColor *layer = CCLayerColor::create();
	layer->setColor( ccGRAY );
	addChild(layer);

	CCSprite* pBK = CCSprite::create( s_szCommonBackgroundImgPath );
	if( pBK )
	{
		CCSize winSize = CCDirector::sharedDirector()->getWinSize();
		pBK->setPosition(ccp(winSize.width / 2, winSize.height / 2));
		layer->addChild( pBK );
	}

	CShaderNode* pShaderNode = CShaderNode::Create( s_szShaderNodeShaderAreaMask, 
		s_szShaderNodeVSH, s_szShaderNodeFSH );

	pShaderNode->setColor(ccc4f(0.0f,0.0f,0.0f,0.5f));
	this->addChild(pShaderNode,2);
}
开发者ID:Pancho2wang,项目名称:cocos2dx_shader_demo,代码行数:23,代码来源:ShaderNode.cpp

示例4: init

bool BillboardScene::init()
{
	bool bRef = false;
	do{
		CC_BREAK_IF(!CCLayer::init());
		this->setContentSize(CCSizeZero);

		CCSize winSize = CCDirector::sharedDirector()->getWinSize();
		CCLayerColor* layerColor = CCLayerColor::create();  

		layerColor->setColor(ccc3(0, 0, 0));  

		layerColor->setOpacity(150);  

		layerColor->setContentSize(CCSizeMake(winSize.width, winSize.height));  
		
		this->addChild(layerColor,0); 
		setTouchEnabled(true);
		bRef = true;
	}while(0);
	return bRef;
}
开发者ID:duanwen200,项目名称:jzds,代码行数:22,代码来源:BillboardScene.cpp

示例5:

//--------------------------------------------------------
// CColorSpriteScene
//--------------------------------------------------------
CRemoveBKSpriteScene::CRemoveBKSpriteScene()
{
	CCLayerColor *layer = CCLayerColor::create( ccc4BFromccc4F(ccc4FFromccc3B( ccGRAY )));
	layer->setColor( ccGRAY );
	addChild(layer);

	CCSize winSize = CCDirector::sharedDirector()->getWinSize();
	CRemoveBKSprite* pRemoveSprite = CRemoveBKSprite::Create( s_szRemoveBKSprite );
	if( pRemoveSprite )
	{
		pRemoveSprite->setPosition(ccp(winSize.width / 2 + pRemoveSprite->getContentSize().width / 2 , 
			winSize.height / 2));
		layer->addChild( pRemoveSprite );
	}
	CCSprite* pNormalSprite = CCSprite::create( s_szRemoveBKSprite );
	if( pNormalSprite )
	{
		pNormalSprite->setPosition(ccp(winSize.width / 2 - pNormalSprite->getContentSize().width / 2 , 
			winSize.height / 2));
		layer->addChild( pNormalSprite );
	}
}
开发者ID:Pancho2wang,项目名称:cocos2dx_shader_demo,代码行数:25,代码来源:RemoveBKSprite.cpp

示例6: tableCellAtIndex


//.........这里部分代码省略.........
        CCLayerColor* colorLayer = CCLayerColor::create(bgColor, SCREEN_WIDTH, CELL_HEIGHT);
        colorLayer->setTag(BACKGROUND_TAG);
        
        cell->addChild(colorLayer);
        
        // Get the sender profile picture path. Create it if path is available.
        if (sender != NULL && strcmp(sender->getPhotoPath(), "") != 0)
        {
            const char*  picPath = sender->getPhotoPath();
            profilePic = CCSprite::create(picPath);
        }
        else
        {
            profilePic = CCSprite::create(FB_DEFAULT_PHOTO);
        }

        // Add the profile pic to the cell row.
        profilePic->setAnchorPoint(ccp(0, 0.5));
        profilePic->setPosition(ccp(20, CELL_HEIGHT/2));
        cell->addChild(profilePic);
        profilePic->setTag(FRIEND_PHOTO_TAG);
        
        // Set the message.
        CCLabelTTF *messageLabel = CCLabelTTF::create(messageToDisplay.c_str(), "Helvetica", 20.0 * MENU_FONT_SCALE);
        messageLabel->setAnchorPoint(ccp(0, 0.5));
        messageLabel->setPosition(ccp(20 + 20 + profilePic->getContentSize().width, CELL_HEIGHT/2));
        messageLabel->setTag(REQUEST_MESSAGE_LABEL_TAG);
        messageLabel->setDimensions(CCSizeMake(SCREEN_WIDTH - (profilePic->getContentSize().width * 2) - 60, CELL_HEIGHT-5));
        messageLabel->setHorizontalAlignment(kCCTextAlignmentLeft);
        cell->addChild(messageLabel);

        CCMenuItemImage* constumeItemButton = NULL;
        constumeItemButton = CCMenuItemImage::create("use.png", "use_pressed.png");
        

        constumeItemButton->setTag(idx);
        constumeItemButton->setTarget(this, menu_selector(RequestList::useItem));
        constumeItemButton->setScale(SCALE_FACTOR * 0.8);
        constumeItemButton->setTag(FRIEND_CONSUME_BUTTON_TAG);
        
        CCMenu* consumeMenu = CCMenu::create(constumeItemButton, NULL);
        consumeMenu->setTag(FRIEND_CONSUME_MENU_TAG);
        consumeMenu->setPosition(ccp(SCREEN_WIDTH - (constumeItemButton->getContentSize().width*SCALE_FACTOR*0.4),
                                       (CELL_HEIGHT - (constumeItemButton->getContentSize().height)*SCALE_FACTOR*0.4)));
        
        
        cell->addChild(consumeMenu);
        
        
    }
    else
    {
        // Refresh the cell data based upon idx.
        
        // 1. Refresh the profile picture.
        CCSprite* cellProfilePic = (CCSprite*)cell->getChildByTag(FRIEND_PHOTO_TAG);
        
        if (strcmp("", sender->getPhotoPath()) != 0 )
        {
            const char*  picPath = sender->getPhotoPath();
            profilePic = CCSprite::create(picPath);
            
        }
        else
        {
            profilePic = CCSprite::create(FB_DEFAULT_PHOTO);
        }
        
        cellProfilePic->setTexture(profilePic->getTexture());
        
        // Update the message Label.
        CCLabelTTF *messageLabel = (CCLabelTTF*)cell->getChildByTag(REQUEST_MESSAGE_LABEL_TAG);
        messageLabel->setString(messageToDisplay.c_str());
        
        CCMenu* consumeMenu = (CCMenu*)cell->getChildByTag(FRIEND_CONSUME_MENU_TAG);
        
        CCArray* children = consumeMenu->getChildren();
        
        if (children)
        {
            CCMenuItemImage* consumenButton = (CCMenuItemImage*)children->objectAtIndex(0);
            
            if (consumenButton)
            {
                consumenButton->setTag(index);
            }
            else
            {
                CCLOG("No Consume Button");
            }
            
        }
        
        CCLayerColor* bgLayer = (CCLayerColor*)cell->getChildByTag(BACKGROUND_TAG);
        bgLayer->setColor(ccc3(bgColor.r, bgColor.g, bgColor.b));
    }
    
    return cell;
    
}
开发者ID:chenbk85,项目名称:EziSocialDemo,代码行数:101,代码来源:RequestList.cpp


注:本文中的CCLayerColor::setColor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。