本文整理汇总了C++中LayerColor类的典型用法代码示例。如果您正苦于以下问题:C++ LayerColor类的具体用法?C++ LayerColor怎么用?C++ LayerColor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LayerColor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LayerColor
LayerColor * LayerColor::create(const Color4B& color, GLfloat width, GLfloat height)
{
LayerColor * layer = new LayerColor();
if( layer && layer->initWithColor(color,width,height))
{
layer->autorelease();
return layer;
}
CC_SAFE_DELETE(layer);
return nullptr;
}
示例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: new
LayerColor * LayerColor::create(const Color4B& color)
{
LayerColor * layer = new (std::nothrow) LayerColor();
if(layer && layer->initWithColor(color))
{
layer->autorelease();
return layer;
}
CC_SAFE_DELETE(layer);
return nullptr;
}
示例4: addCtrlPanel
void SceneGame::addCtrlPanel()
{
Menu* menu = Menu::create();
this->addChild(menu);
LayerColor* bg = LayerColor::create(Color4B(150, 80, 50, 255), winSize.width, winSize.height);
addChild(bg, -1);
bg->setGlobalZOrder(-300);
MenuItemImage *regretItem = MenuItemImage::create("regret.jpg", "regret.jpg"
, CC_CALLBACK_1(SceneGame::Regret,this));
menu->addChild(regretItem);
moveNode(regretItem, Vec2(160, 60));
MenuItem* startServerItem = MenuItemFont::create("StartServer",CC_CALLBACK_1(SceneGame::startServer,this));
menu->addChild(startServerItem);
moveNode(startServerItem, Vec2(160, 0));
MenuItem* startClientItem = MenuItemFont::create("StartClient",CC_CALLBACK_1(SceneGame::startClient,this));
menu->addChild(startClientItem);
moveNode(startClientItem, Vec2(160, -60));
startServerItem->setUserObject(startClientItem);
startClientItem->setUserObject(startServerItem);
MenuItem* restartItem = MenuItemFont::create("Restart", CC_CALLBACK_1(SceneGame::Restart,this));
menu->addChild(restartItem);
moveNode(restartItem, Vec2(160, -120));
if (_bRestart)
{
startServerItem->setEnabled(false);
startClientItem->setEnabled(false);
NetBattle::clear();
if (_bRedSide)
{
startServer(startServerItem);
}
else
{
startClient(startClientItem);
}
}
}
示例5: new
LayerColor* LayerColor::create()
{
LayerColor* ret = new (std::nothrow) LayerColor();
if (ret && ret->init())
{
ret->autorelease();
}
else
{
CC_SAFE_DELETE(ret);
}
return ret;
}
示例6: unschedule
//游戏成功
void Breakout::win() {
unschedule(schedule_selector(Breakout::update));
unschedule(schedule_selector(Breakout::showTime));
LayerColor* gameOverLayer = LayerColor::create(Color4B(128, 128, 128, 128));
Label* over = Label::createWithSystemFont("You Win", "Arial", 80);
over->setPosition(origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2);
gameOverLayer->addChild(over);
this->addChild(gameOverLayer, 5);
for (int i = 0; i < enemys.size(); i++) {
enemys.at(i)->setVelocity(Vec2(0, 0));
}
player->getPhysicsBody()->setVelocity(Vec2(0, 0));
}
示例7: setupHeader
void TDDSubMenu::setupHeader(const Color4B &headerColor)
{
GLfloat parentH = this->getContentSize().height;
GLfloat width = this->getContentSize().width;
GLfloat height = kHeaderHeight;
LayerColor *headerLayer = LayerColor::create(headerColor, width, height);
Point pos = Point(0, parentH - height);
headerLayer->setPosition(pos);
this->addChild(headerLayer);
// Setting Buttons
float scale = TDDHelper::getBestScale();
// Size screenSize = TDDHelper::getScreenSize();
int midY = height/2;
int buttonW = (int)(scale * 50);
int buttonH = height;
int leftButtonX = buttonW / 2;
int rightButtonX = width - leftButtonX;
int midX = width/2;
Size size = Size(buttonW, buttonH);
ControlButton *button;
pos.x = leftButtonX;
pos.y = midY;
button = createButton("back", kActionTagBack, pos, size);
headerLayer->addChild(button);
mBackButton = button;
pos.x = rightButtonX;
pos.y = midY;
button = createButton("hide", kActionTagToggle, pos, size);
headerLayer->addChild(button);
button->addTargetWithActionForControlEvents(this,
cccontrol_selector(TDDSubMenu::touchUpInsideAction),
Control::EventType::TOUCH_UP_INSIDE);
mToggleButton = button;
// Label
Label *title = Label::createWithSystemFont("MENU", "Arial", 15);
title->setColor(Color3B::WHITE);
title->setPosition(Point(midX, midY));
headerLayer->addChild(title);
//
mHeaderLayer = headerLayer;
}
示例8: init
bool BuyChipLayer::init()
{
if(!PokerChildLayer::init()) {
return false;
}
LayerColor *layer = LayerColor::create(Color4B(100,100,100,100));
this->addChild(layer);
this->setTouchMode(Touch::DispatchMode::ONE_BY_ONE);
this->setTouchEnabled(true);
this->setSwallowsTouches(true);
auto& size = Director::getInstance()->getWinSize();
auto layout = ui::Layout::create();
layout->setContentSize(size);
layout->setTouchEnabled(true);
layout->setAnchorPoint(Point::ZERO);
this->addChild(layout, -10);
auto root = CSLoader::createNode("LayerBuyChip1.csb");
this->addChild(root);
Size winSize = Director::getInstance()->getWinSize();
LayerColor *layerBlack = LayerColor::create(Color4B(0, 0, 0, 100),winSize.width,winSize.height * 2);
layerBlack->setPositionY(-winSize.height);
this->addChild(layerBlack,-1);
auto text_max_add = dynamic_cast<Text*>(CSLoader::seekNodeByName(root, "text_max_add"));
auto text_min_add = dynamic_cast<Text*>(CSLoader::seekNodeByName(root, "text_min_add"));
text_max_add->setString(tools::local_string("max_buy", "最多可添加"));
text_min_add->setString(tools::local_string("min_buy", "最少可添加"));
text_min_number_ = dynamic_cast<Text*>(CSLoader::seekNodeByName(root, "text_min_number"));
text_max_number_ = dynamic_cast<Text*>(CSLoader::seekNodeByName(root, "text_max_number"));
text_buy_number_ = dynamic_cast<Text*>(CSLoader::seekNodeByName(root, "text_buy_number"));
auto btn_cancel = dynamic_cast<Button *>(CSLoader::seekNodeByName(root, "btn_cancel"));
auto btn_confirm = dynamic_cast<Button*>(CSLoader::seekNodeByName(root, "btn_confirm"));
btn_cancel->addClickEventListener(std::bind(&BuyChipLayer::click_btn_cancel, this, std::placeholders::_1));
btn_confirm->addClickEventListener(std::bind(&BuyChipLayer::click_btn_confirm, this, std::placeholders::_1));
btn_cancel->setTitleText(tools::local_string("cancel","取消"));
btn_confirm->setTitleText(tools::local_string("confirm_change_password","确定"));
auto btn_add = dynamic_cast<Button*>(CSLoader::seekNodeByName(root, "btn_add"));
auto btn_sub = dynamic_cast<Button*>(CSLoader::seekNodeByName(root, "btn_sub"));
btn_add->addClickEventListener(std::bind(&BuyChipLayer::click_btn_add, this, std::placeholders::_1));
btn_sub->addClickEventListener(std::bind(&BuyChipLayer::click_btn_sub, this, std::placeholders::_1));
slider_chip_ = dynamic_cast<Slider*>(CSLoader::seekNodeByName(root, "slider_chip"));
slider_chip_->addEventListener(std::bind(&BuyChipLayer::slider_slider_chip, this, std::placeholders::_1, std::placeholders::_2));
return true;
}
示例9: init
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !Layer::init() )
{
return false;
}
visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();
/////////////////////////////
// 2. add a menu item with "X" image, which is clicked to quit the program
// you may modify it.
/**/
// add "HelloWorld" splash screen"
auto sprite = Sprite::create("bkq.png");
// position the sprite on the center of the screen
sprite->setPosition(Vec2(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
// add the sprite as a child to this layer
// this->addChild(sprite, 0);
sprite->setTag(1024);
//scheduleUpdate();
//schedule(schedule_selector(HelloWorld::updateTest), 1.0f, kRepeatForever,5.0f);
/**/
//color4b rgbA LayerColorĬÈÏêµã0,0
LayerColor* redLayer = LayerColor::create(Color4B(255, 0, 0, 255), visibleSize.width / 2, visibleSize.height / 2);
redLayer->ignoreAnchorPointForPosition(false);
redLayer->setPosition(visibleSize / 2);
redLayer->setAnchorPoint(Vec2(0.5, 0.5));
this->addChild(redLayer);
LayerColor* blueLayer = LayerColor::create(Color4B(0, 0, 255, 255), visibleSize.width / 6, visibleSize.height / 6);
blueLayer->ignoreAnchorPointForPosition(false);
blueLayer->setAnchorPoint(Vec2(1, 1));
redLayer->addChild(blueLayer);
/*
DrawNode * rect = DrawNode::create();
addChild(rect);
rect->setZOrder(10);
rect->drawSolidRect(Vec2(100,100),Vec2(300,300),Color4F(1,0,0,1));
DrawNode * rect2 = DrawNode::create();
addChild(rect2);
rect2->drawSolidRect(Vec2(150, 150), Vec2(350, 350), Color4F(0, 1, 0, 1));
DrawNode * rect3 = DrawNode::create();
addChild(rect3);
rect3->drawSolidRect(Vec2(200, 200), Vec2(400, 400), Color4F(0, 0, 1, 1));
*/
return true;
}
示例10: 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;
}
示例11: initTitulo
void Ajustes::initTitulo(){
LayerColor *capaPosTitulo = LayerColor::create(Color4B(23, 70, 108, 210), cuadroJuego->getContentSize().width-(espacioBordesCuadro*escala*2), 200*escala);
capaPosTitulo->setAnchorPoint(Vec2(0,1));
capaPosTitulo->setPosition(anchoLateralCE+(espacioSuperiorBtAtras*escala),visibleSize.height-(200*escala)-(espacioSuperiorBtAtras*escala));
capaPosTitulo->setZOrder(1);
this->addChild(capaPosTitulo);
tituloEscena = CCLabelTTF::create(LanguageManager::getInstance()->getString("AjustesLbTitulo"), "HVD_Comic_Serif_Pro.ttf", 130*escala,CCSizeMake(anchoNoLateralCE, capaPosTitulo->getContentSize().height), TextHAlignment::CENTER);
tituloEscena->setColor(Color3B(216,254,51));
tituloEscena->setVerticalAlignment(TextVAlignment::CENTER);
tituloEscena->setAnchorPoint(Vec2(0, 0));
tituloEscena->setPosition(anchoLateralCE,capaPosTitulo->getPositionY());
tituloEscena->setZOrder(10);
this->addChild(tituloEscena, 1);
tituloEscena->retain();
}
示例12: getContentSize
void TTTBoard::addHorizontalGrids()
{
Color4B color = TTT_LINE_COLOR;
int numLine = mGrid - 1;
float lineThick = 6;
float lineWidth = getContentSize().width;
float y = (mGridSize - lineThick/2);
Point pos = Point(0, y);
for(int i=0; i<numLine; i++) {
LayerColor *line = LayerColor::create(color, lineWidth, lineThick);
line->setPosition(pos);
addChild(line);
pos.y += mGridSize;
}
}
示例13: CC_CALLBACK_2
// on "init" you need to initialize your instance
bool Bug914Layer::init()
{
// always call "super" init
// Apple recommends to re-assign "self" with the "super" return value
if (BugsTestBaseLayer::init())
{
auto listener = EventListenerTouchAllAtOnce::create();
listener->onTouchesBegan = CC_CALLBACK_2(Bug914Layer::onTouchesBegan, this);
listener->onTouchesMoved = CC_CALLBACK_2(Bug914Layer::onTouchesMoved, this);
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
// ask director the the window size
auto size = Director::getInstance()->getWinSize();
LayerColor *layer;
for( int i=0;i < 5;i++)
{
layer = LayerColor::create(Color4B(i*20, i*20, i*20,255));
layer->setContentSize(Size(i*100, i*100));
layer->setPosition(Vec2(size.width/2, size.height/2));
layer->setAnchorPoint(Vec2(0.5f, 0.5f));
layer->ignoreAnchorPointForPosition(false);
addChild(layer, -1-i);
}
// create and initialize a Label
auto label = Label::createWithTTF("Hello World", "fonts/Marker Felt.ttf", 64.0f);
auto item1 = MenuItemFont::create("restart", CC_CALLBACK_1(Bug914Layer::restart, this));
auto menu = Menu::create(item1, nullptr);
menu->alignItemsVertically();
menu->setPosition(Vec2(size.width/2, 100));
addChild(menu);
// position the label on the center of the screen
label->setPosition(Vec2( size.width /2 , size.height/2 ));
// add the label as a child to this Layer
addChild(label);
return true;
}
return false;
}
示例14: init
bool LoadingScene::init()
{
if (Layer::init())
{
// add background to current scene
LayerColor *bkGround = LayerColor::create(Color4B(0, 255, 255, 255));
this->addChild(bkGround);
LabelTTF *logo = LabelTTF::create("tashaxing's 2048", "Arial", 30);
logo->setColor(Color3B(255, 255, 0));
bkGround->addChild(logo);
logo->setPosition(bkGround->getContentSize().width / 2, bkGround->getContentSize().height / 2);
//添加音频预加载回调,注意,只有layer才能用schedule,scene不行
this->scheduleOnce(schedule_selector(LoadingScene::loadingCallBack), 0);
return true;
}
else
{
return false;
}
}
示例15: 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);
}