本文整理汇总了C++中LayerColor::setOpacity方法的典型用法代码示例。如果您正苦于以下问题:C++ LayerColor::setOpacity方法的具体用法?C++ LayerColor::setOpacity怎么用?C++ LayerColor::setOpacity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LayerColor
的用法示例。
在下文中一共展示了LayerColor::setOpacity方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
bool GameNext::init()
{
//////////////////////////////
// 1. super init first
if (!Scene::init())
{
return false;
}
Size visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();
/////////////////////////////
if(game_round<=9)
{
gr_pic = "0" + Value(game_round).asString();
}else if(game_round>=10)
{
gr_pic = Value(game_round).asString();
}
if((game_level-1)<=9)
{
gl_pic = "0" + Value(game_level-1).asString();
}else if((game_level-1)>=10)
{
gl_pic = Value(game_level-1).asString();
}
//被弄成灰色的截图
auto ac = Sprite::create(picNext);
ac->setAnchorPoint(Vec2(0,0));
ac->setPosition(Vec2(0,0));
ac->setScaleX(visibleSize.width/ac->getTextureRect().getMaxX()); //设置精灵宽度缩放比例
ac->setScaleY(visibleSize.height/ac->getTextureRect().getMaxY());
this->addChild(ac,100);
//半透明层,在截图之上
LayerColor* layerColor = CCLayerColor::create();
layerColor->setColor(cocos2d::Color3B(0, 0, 0));
layerColor->setOpacity(150);
layerColor->setContentSize(Size(visibleSize.width, visibleSize.height));
this->addChild(layerColor,101);
//next小方块的背景
auto gameover = Sprite::create("setting/gamenext.png");
gameover->setPosition(Vec2(origin.x + visibleSize.width/2,origin.y + visibleSize.height/2));
this->addChild(gameover,102);
scheduleUpdate();
return true;
}
示例2: init
bool GameOver::init()
{
//////////////////////////////
// 1. super init first
if (!Scene::init())
{
return false;
}
Size visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();
/////////////////////////////
auto ac = Sprite::create(picOver);
ac->setAnchorPoint(Vec2(0,0));
ac->setPosition(Vec2(0,0));
ac->setScaleX(visibleSize.width/ac->getTextureRect().getMaxX()); //设置精灵宽度缩放比例
ac->setScaleY(visibleSize.height/ac->getTextureRect().getMaxY());
this->addChild(ac,100);
//半透明层
LayerColor* layerColor = CCLayerColor::create();
layerColor->setColor(cocos2d::Color3B(0, 0, 0));
layerColor->setOpacity(150);
layerColor->setContentSize(Size(visibleSize.width, visibleSize.height));
this->addChild(layerColor,101);
auto gameover = Sprite::create("setting/gameover.png");
//gameover->setAnchorPoint(Vec2(0,0));
gameover->setPosition(Vec2(origin.x + visibleSize.width/2,
origin.y + visibleSize.height/2));
this->addChild(gameover,102);
scheduleUpdate();
return true;
}
示例3: init
bool GameWinLayer::init()
{
if (!Layer::init())
{
return false;
}
Size visibleSize = Director::sharedDirector()->getVisibleSize();
// finish layer
LayerColor* layerColor = LayerColor::create();
layerColor->setColor(Color3B(0, 0, 0));
layerColor->setOpacity(150);
layerColor->setContentSize(Size(visibleSize.width, visibleSize.height));
this->addChild(layerColor, 1);
return true;
}
示例4: onEnter
void GameOverDialog::onEnter() {
Node::onEnter();
Size visibleSize = Director::getInstance()->getVisibleSize();
// this->setContentSize(visibleSize);
LayerColor *background = LayerColor::create(Color4B(0, 0, 0, 178));
this->addChild(background);
// background->setContentSize(visibleSize);
// TODO: We should decide winner in the game scene
std::string filename = _playerLifePoint == _opponentLifePoint
? "labelDraw.png"
: (_playerLifePoint > _opponentLifePoint ? "labelYouWin.png" : "labelYouLose.png");
Sprite *title = Sprite::create(filename);
title->setAnchorPoint(Vec2::ANCHOR_MIDDLE_TOP);
title->setPosition(Vec2(visibleSize.width * 0.5f, visibleSize.height * 0.9f));
std::stringstream ss;
ss << _playerLifePoint * 100 / INITIAL_PLAYER_LIFE << "% - " << _opponentLifePoint * 100 / INITIAL_PLAYER_LIFE
<< "%";
// TODO: Do not use magic number
auto scoreLabel = ui::Text::create(ss.str(), FONT_DIGIT, 96);
scoreLabel->setAnchorPoint(Vec2(0.5f, 0.5f));
scoreLabel->setPosition(Vec2(visibleSize.width * 0.5f, visibleSize.height * 0.5f));
scoreLabel->setColor(Color3B::WHITE);
_button = ui::Button::create();
_button->loadTextures("buttonOk.png", "buttonOkPressed.png");
_button->setAnchorPoint(Vec2::ANCHOR_MIDDLE_BOTTOM);
_button->setPosition(Vec2(visibleSize.width * 0.5f, visibleSize.height * 0.1f));
_button->addTouchEventListener(CC_CALLBACK_2(GameOverDialog::buttonPressed, this));
this->addChild(title);
this->addChild(scoreLabel);
this->addChild(_button);
auto action = cocos2d::FadeTo::create(0.1, 178);
background->setOpacity(0);
background->runAction(action);
}