本文整理汇总了C++中CCLayerColor::setOpacity方法的典型用法代码示例。如果您正苦于以下问题:C++ CCLayerColor::setOpacity方法的具体用法?C++ CCLayerColor::setOpacity怎么用?C++ CCLayerColor::setOpacity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCLayerColor
的用法示例。
在下文中一共展示了CCLayerColor::setOpacity方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: 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;
}
示例3: gameOver
void GameScene::gameOver()
{
CCRingSprite* pRing;
for(std::list<int>::iterator itr = CCRingSprite::s_tags.begin(); itr != CCRingSprite::s_tags.end() ; itr++){
pRing = (CCRingSprite*)this->getChildByTag(*itr);
pRing->unscheduleUpdate();
}
getChildByTag(kTagBackground)->unscheduleUpdate();
m_pBattery->stopUserInput();
CCTintTo* toWhite = CCTintTo::create(2.0f,255,255,255);
m_pScoreLabel->runAction(toWhite);
CCLayerColor* gameOverLayer = CCLayerColor::create(ccc4(0,0,0,128),m_winSize.width,m_winSize.height);
gameOverLayer->setAnchorPoint(CCPointZero);
gameOverLayer->setPosition(ccp(0,m_winSize.height));
gameOverLayer->setOpacity(0);
CCActionInterval* fade = CCFadeIn::create(1.0f);
CCMoveTo* move = CCMoveTo::create(0.4f,CCPointZero);
gameOverLayer->runAction(CCEaseSineIn::create(CCSpawn::createWithTwoActions(fade,move)));
this->addChild(gameOverLayer,kZOrderGameOverLayer,kTagGameOverLayer);
CCDelayTime* delay = CCDelayTime::create(0.3f);
CCCallFunc* ad = CCCallFunc::create(this, callfunc_selector( GameScene::callAd) );
this->runAction(CCSequence::createWithTwoActions(delay,ad));
saveScore();
showRetryButtons();
SimpleAudioEngine::sharedEngine()->playBackgroundMusic("sounds/GameOver.mp3",false);
m_gameState = kStateGameOver;
}
示例4: showMessageParking
void AlertViewScene::showMessageParking(CCNode* parent, SEL_MenuHandler callbackFunction ,int wayPoint)
{
int basePosition = 50;
float heigth = CCDirector::sharedDirector()->getWinSize().height;
if (heigth >480) {
basePosition = 100;//4inch
}
if( AlertViewScene::isActive == true)
return;
AlertViewScene::isActive = true;
//Layer - Container with all elements of Alert
CCLayerColor *node = CCLayerColor::create(ccc4(0,0,0,255));
node->setContentSize(CCDirector::sharedDirector()->getWinSize());
node->setOpacity(200);
node->setAnchorPoint(ccp(0,0));
node->setPosition(ccp(0,0));
//Fundo do Popup
CCSprite *sprBackground = CCSprite::create("popup.png");
sprBackground->setAnchorPoint(ccp(0,0));
sprBackground->setScale(1);
sprBackground->setPosition(ccp( 25,basePosition+100));
node->addChild(sprBackground);
//Close Button of frame
CCSprite *btnClose = CCSprite::create("fechar_btn.png");
CCSprite *btnClosePress = CCSprite::create("fechar_press.png");
CCSprite *Icone = CCSprite::create("icone_estacionamento.png");
Icone->setPosition(ccp(45,basePosition+225));
node->addChild(Icone);
CCMenuItemSprite *itembtnClose = CCMenuItemSprite::create(btnClose, btnClosePress, node, callbackFunction);
itembtnClose->setAnchorPoint(ccp(0, 0));
itembtnClose->setPosition(ccp(280,basePosition+303));
//Button Rota para o local
CCSprite *btnSelect = CCSprite::create("ok_btn.png");
CCSprite *btnUnselect = CCSprite::create("ok_press.png");
CCMenuItemSprite *itembtnRota = CCMenuItemSprite::create( btnSelect,btnUnselect, node,callbackFunction);
itembtnRota->setAnchorPoint(ccp(0, 0));
itembtnRota->setPosition(ccp(115,basePosition+150));
//Button Rota para o local
CCMenu* options = CCMenu::create();
options->addChild(itembtnClose,0,44);
options->addChild(itembtnRota,0,wayPoint);
options->setPosition(ccp(0, -20));
node->addChild(options,3,Global::TAG_Child_Layer);
//Title of Alert
CCLabelTTF *labelTitle;
labelTitle = CCLabelTTF::create("Alerta", "LucidaGrandeBold", 16);
labelTitle->setPosition(ccp(35, basePosition+260));
labelTitle->setAnchorPoint(ccp(0,0));
labelTitle->setColor(ccc3(55, 55, 55));
node->addChild(labelTitle);
//sub-Title of Alert
CCLabelTTF *labelSubTitle;
labelSubTitle = CCLabelTTF::create("Atenção", "LucidaGrandeBold", 11);
labelSubTitle->setPosition(ccp(60, basePosition+225));
labelSubTitle->setAnchorPoint(ccp(0,0));
labelSubTitle->setColor(ccc3(55, 55, 55));
node->addChild(labelSubTitle);
//Description of Alert
CCLabelTTF *labelDescription;
labelDescription = CCLabelTTF::create(" Ao entrar por este bloco você só poderá retirar", "Lucida Grande", 10);
labelDescription->setPosition(ccp(40, basePosition+210));
labelDescription->setAnchorPoint(ccp(0,0));
labelDescription->setColor(ccc3(55, 55, 55));
node->addChild(labelDescription);
//Description of Alert
CCLabelTTF *labelDescription2;
labelDescription2 = CCLabelTTF::create("seu veículo neste mesmo bloco.", "Lucida Grande", 10);
labelDescription2->setPosition(ccp(35, basePosition+200));
labelDescription2->setAnchorPoint(ccp(0,0));
labelDescription2->setColor(ccc3(55, 55, 55));
node->addChild(labelDescription2);
parent->addChild(node,10,Global::TAG_Alert_Layer);
}
示例5: showMessageSearch
void showMessageSearch(CCNode* sender, SEL_MenuHandler callbackFunction)
{
if( AlertViewScene::isActive == true)
return;
AlertViewScene::isActive = true;
//Layer - Container with all elements of Alert
CCLayerColor *node = CCLayerColor::create(ccc4(0,0,0,255));
node->setContentSize(CCDirector::sharedDirector()->getWinSize());
node->setOpacity(200);
node->setAnchorPoint(ccp(0,0));
node->setPosition(ccp(0,0));
//Fundo do Popup
CCSprite *sprBackground = CCSprite::create("popup.png");
sprBackground->setAnchorPoint(ccp(0,0));
sprBackground->setScale(1);
sprBackground->setPosition(ccp(25,100));
node->addChild(sprBackground);
//Close Button of frame
// CCSprite *btnClose = CCSprite::create("fechar_btn.png");
// CCSprite *btnClosePress = CCSprite::create("fechar_press.png");
// CCSprite *Icone = CCSprite::create("icone_estacionamento.png");
// Icone->setPosition(ccp(45,225));
// node->addChild(Icone);
// CCMenuItemSprite *itembtnClose = CCMenuItemSprite::create(btnClose, btnClosePress, node, callbackFunction);
// itembtnClose->setAnchorPoint(ccp(0, 0));
// itembtnClose->setPosition(ccp(280,303));
//Button Rota para o local
// CCSprite *btnSelect = CCSprite::create("ok_btn.png");
// CCSprite *btnUnselect = CCSprite::create("ok_press.png");
// CCMenuItemSprite *itembtnRota = CCMenuItemSprite::create( btnSelect,btnUnselect, node,callbackFunction);
// itembtnRota->setAnchorPoint(ccp(0, 0));
// itembtnRota->setPosition(ccp(115,150));
// //Button Rota para o local
// CCMenu* options = CCMenu::create();
// options->addChild(itembtnClose,0,44);
// options->addChild(itembtnRota,0,wayPoint);
// options->setPosition(ccp(0, -20));
// node->addChild(options,3,Global::TAG_Child_Layer);
//Title of Alert
CCLabelTTF *labelTitle;
labelTitle = CCLabelTTF::create("Alerta", "LucidaGrandeBold", 16);
labelTitle->setPosition(ccp(35, 260));
labelTitle->setAnchorPoint(ccp(0,0));
labelTitle->setColor(ccc3(55, 55, 55));
node->addChild(labelTitle);
//sub-Title of Alert
CCLabelTTF *labelSubTitle;
labelSubTitle = CCLabelTTF::create("Atenção", "LucidaGrandeBold", 11);
labelSubTitle->setPosition(ccp(60, 225));
labelSubTitle->setAnchorPoint(ccp(0,0));
labelSubTitle->setColor(ccc3(55, 55, 55));
node->addChild(labelSubTitle);
//Description of Alert
CCLabelTTF *labelDescription;
labelDescription = CCLabelTTF::create(" Sua busca retornou muitos resultados.", "Lucida Grande", 10);
labelDescription->setPosition(ccp(40, 210));
labelDescription->setAnchorPoint(ccp(0,0));
labelDescription->setColor(ccc3(55, 55, 55));
node->addChild(labelDescription);
//Description of Alert
// CCLabelTTF *labelDescription2;
// labelDescription2 = CCLabelTTF::create(".", "Lucida Grande", 10);
// labelDescription2->setPosition(ccp(35, 200));
// labelDescription2->setAnchorPoint(ccp(0,0));
// labelDescription2->setColor(ccc3(55, 55, 55));
// node->addChild(labelDescription2);
sender->addChild(node,10,Global::TAG_Alert_Layer);
}
示例6: showMessageRota
void AlertViewScene::showMessageRota(CCNode* sender, SEL_MenuHandler callbackFunction ,int wayPoint)
{
if( AlertViewScene::isActive == true)
return;
AlertViewScene::isActive = true;
//Backgroud Alert
CCSprite *sprBackground = CCSprite::create("popup.png");
sprBackground->setAnchorPoint(ccp(0,0));
sprBackground->setScale(1);
sprBackground->setPosition(ccp(25,100));
//Layer - Container with all elements of Alert
CCLayerColor *node = CCLayerColor::create(ccc4(0,0,0,255));
node->setContentSize(CCDirector::sharedDirector()->getWinSize());
node->addChild(sprBackground);
node->setOpacity(200);
node->setAnchorPoint(ccp(0,0));
node->setPosition(ccp(0,0));
//Close Button of frame
CCSprite *btnClose = CCSprite::create("fechar_btn.png");
CCSprite *btnClosePress = CCSprite::create("fechar_press.png");
CCSprite *Icone = CCSprite::create("icone_horario.png");
Icone->setPosition(ccp(45,225));
node->addChild(Icone);
CCMenuItemSprite *itembtnClose = CCMenuItemSprite::create(btnClose, btnClosePress, node, menu_selector(AlertViewScene::btnCloseAlert));
itembtnClose->setAnchorPoint(ccp(0, 0));
itembtnClose->setPosition(ccp(280,303));
//Button Rota para o local
CCSprite *btnSelect = CCSprite::create("Rota_btn.png");
CCSprite *btnUnselect = CCSprite::create("Rota_press.png");
CCMenuItemSprite *itembtnRota = CCMenuItemSprite::create( btnSelect,btnUnselect, node,callbackFunction);
itembtnRota->setAnchorPoint(ccp(0, 0));
itembtnRota->setPosition(ccp(80,150));
//Button Rota para o local
CCMenu* options = CCMenu::create();
options->addChild(itembtnClose,0,44);
options->addChild(itembtnRota,0,wayPoint);
options->setPosition(ccp(0, -20));
node->addChild(options,3,Global::TAG_Child_Layer);
//Title of Alert
CCLabelTTF *labelTitle;
labelTitle = CCLabelTTF::create(IFixedMenu::LoadWayPointName(wayPoint), "LucidaGrandeBold", 16);
labelTitle->setPosition(ccp(35, 260));
labelTitle->setAnchorPoint(ccp(0,0));
labelTitle->setColor(ccc3(55, 55, 55));
node->addChild(labelTitle);
CCLabelTTF *labelSubTitle;
labelSubTitle = CCLabelTTF::create("Horário de funcionamento", "LucidaGrandeBold", 11);
labelSubTitle->setPosition(ccp(60, 225));
labelSubTitle->setAnchorPoint(ccp(0,0));
labelSubTitle->setColor(ccc3(55, 55, 55));
node->addChild(labelSubTitle);
//Description of Alert
CCLabelTTF *labelDescription;
labelDescription = CCLabelTTF::create("Estamos abertos todos os dias das 9h as 24h*", "Lucida Grande", 10);
labelDescription->setPosition(ccp(60, 210));
labelDescription->setAnchorPoint(ccp(0,0));
labelDescription->setColor(ccc3(55, 55, 55));
node->addChild(labelDescription);
((CCLayerColor*)sender)->setOpacity(30);
CCDirector::sharedDirector()->getRunningScene()->addChild(node,10,Global::TAG_Alert_Layer);
}