本文整理汇总了C++中Color4B函数的典型用法代码示例。如果您正苦于以下问题:C++ Color4B函数的具体用法?C++ Color4B怎么用?C++ Color4B使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Color4B函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: renderIcon
void renderIcon(const String &data, uint16_t column, uint16_t row) {
uint32_t xOffset = column * _canvasWidth;
uint32_t yOffset = row * _canvasHeight;
_canvas->save();
_canvas->translate(xOffset / ((float)_canvasWidth / (float)_originalWidth), yOffset / ((float)_canvasHeight / (float)_originalHeight));
Rc<draw::Path> path;
if (data.compare(0, 7, "path://") == 0) {
path = Rc<draw::Path>::create(data.substr(7));
} else {
path = Rc<draw::Path>::create(FilePath(data));
}
if (!path) {
return;
}
path->setFillColor(Color4B(255, 255, 255, 255));
path->drawOn(_canvas);
_canvas->restore();
}
示例2: CC_CALLBACK_2
bool GameScene::init()
{
if ( !Layer::init() )
{
return false;
}
Size visibleSize = Director::getInstance()->getVisibleSize();
Point origin = Director::getInstance()->getVisibleOrigin();
//设置触摸事件监听
auto touchListener = EventListenerTouchOneByOne::create();
touchListener->onTouchBegan = CC_CALLBACK_2(GameScene::onTouchBegan, this);
touchListener->onTouchEnded = CC_CALLBACK_2(GameScene::onTouchEnded, this);
_eventDispatcher->addEventListenerWithSceneGraphPriority(touchListener, this);
//加入游戏背景
auto layerColorBG = LayerColor::create(Color4B(180, 170, 160, 255));
this->addChild(layerColorBG);
//创建分数
auto cardNumberTitle = LabelTTF::create("SCORE","Consolas",80);
cardNumberTitle->setPosition(Point(visibleSize.width/2 + 340, visibleSize.height/2 + 130));
addChild(cardNumberTitle);
score = 0;
cardNumberTTF = LabelTTF::create("0", "Consolas", 70);
cardNumberTTF->setPosition(Point(visibleSize.width/2 + 340, visibleSize.height/2 - 100));
addChild(cardNumberTTF);
//创建4X4卡片
createCardSprite(visibleSize);
//初始时生成两个2
createCardNumber();
createCardNumber();
return true;
}
示例3: init
// on "init" you need to initialize your instance
bool MainLoadingScene::init()
{
if ( !Scene::init() )
{
return false;
}
LayerColor *layer = LayerColor::create();
layer->initWithColor(Color4B(255, 255, 255, 255), VisibleRect::right().x , VisibleRect::top().y);
layer->setPosition(VisibleRect::center());
layer->setAnchorPoint(Vec2(0.5f, 0.5f));
layer->setIgnoreAnchorPointForPosition(false);
this->addChild(layer, 0);
Sprite *fondo = Sprite::create("fondo.png");
fondo->setPosition(VisibleRect::center());
this->addChild(fondo);
Sprite *sprite = Sprite::create("logo.png");
sprite->setPosition(VisibleRect::center());
this->addChild(sprite);
Label *progress = Label::createWithTTF ("Kargatzen ari da.\nMesedez, minutu pare bat itxaron.", "fonts/PT_Sans-Web-Regular.ttf", 10);
progress->setPosition(Vec2(VisibleRect::center().x, VisibleRect::bottom().y + 12));
progress->setAnchorPoint(Vec2(0.5,0.5));
progress->setColor(Color3B(0,0,0));
addChild(progress);
loading = Sprite::create("loading.png");
loading->setPosition(Vec2(VisibleRect::center().x, VisibleRect::bottom().y + progress->getContentSize().height + loading->getContentSize().height / 2));
addChild(loading);
ActionInterval* rotate = RotateBy::create(5.0f, 360.0f);
RepeatForever *repeat = RepeatForever::create(rotate);
loading->runAction(repeat);
return true;
}
示例4: setTouchEnabled
MainLayer::MainLayer()
{
setTouchEnabled(true);
setTouchMode(Touch::DispatchMode::ONE_BY_ONE);
auto sprite = Sprite::create(s_pathGrossini);
auto layer = LayerColor::create(Color4B(255,255,0,255));
addChild(layer, -1);
addChild(sprite, 0, kTagSprite);
sprite->setPosition( Point(20,150) );
sprite->runAction( JumpTo::create(4, Point(300,48), 100, 4) );
layer->runAction( RepeatForever::create(
Sequence::create(
FadeIn::create(1),
FadeOut::create(1),
NULL)
));
}
示例5: init
bool TetrisGameAreaLayer::init()
{
LayerColor::initWithColor(Color4B(255, 100, 100, 255));
auto keyListener = EventListenerKeyboard::create();
keyListener->setEnabled(true);
keyListener->onKeyReleased = std::bind(&TetrisGameAreaLayer::onKeyReleased, this, std::placeholders::_1,std::placeholders::_2);
keyListener->onKeyPressed = std::bind(&TetrisGameAreaLayer::onKeyDown, this, std::placeholders::_1, std::placeholders::_2);
_eventDispatcher->addEventListenerWithSceneGraphPriority(keyListener, this);
auto dtor = Director::getInstance();
Size vSize = dtor->getVisibleSize();
Vec2 org = dtor->getVisibleOrigin();
//left bottom
Vec2 vlb(org.x + KWBorder, org.y + KHBorder);
int areaHeight = vSize.height * KAreaHRationInVisible;
setContentSize(Size(areaHeight / 2 - 2 * KWBorder, areaHeight - 4 * KWBorder));
setAnchorPoint(Vec2(0 ,0));
setPosition(vlb);
initBlockRectSprite();
//schedule(schedule_selector(TetrisGameAreaLayer::onBlockUpdate), 0.0);
scheduleUpdate();
return true;
}
示例6: init
// on "init" you need to initialize your instance
void UILayer::init(cocos2d::Node* parent) {
Layer = this;
auto vis = Director::getInstance()->getOpenGLView()->getVisibleRect();
auto height = vis.size.height - VisibleRect::top().y;
mLayer = LayerColor::create(Color4B(0x1E,0xB5,0xC7,0xFF), VisibleRect::right().x, height);
parent->addChild(mLayer, 1500);
mLayer->setPositionY(VisibleRect::top().y);
TTFConfig config("fonts/Montserra.ttf",15);
mFileNameLabel = Label::createWithTTF(config,"");
mFileNameLabel->setPosition(0,30);
mLayer->addChild(mFileNameLabel);
auto uiLayer = new UIColorEditor();
uiLayer->init(mLayer);
setFileName("untitled");
}
示例7: init
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
if ( !LayerColor::initWithColor(Color4B(255,255,255,255)) )
{
return false;
}
Size visibleSize = Director::getInstance()->getVisibleSize();
//创建精灵
auto player = Sprite::create("Player.png", Rect(0, 0, 27, 40));
player->setPosition(Point(player->getContentSize().width/2, visibleSize.height / 2));
this->addChild(player, 0);
//更新函数
this->schedule(schedule_selector(HelloWorld::gameLogic), 1.0f);
this->scheduleUpdate();
CocosDenshion::SimpleAudioEngine::getInstance()->playBackgroundMusic("background-music-aac.caf");
return true;
}
示例8: init
bool FrameLayer::init()
{
if (!LayerColor::initWithColor(Color4B(0, 0, 0, 0)))
{
return false;
}
auto l1 = Sprite::create("frame/l.png");
auto l2 = Sprite::create("frame/l.png");
l1->setPosition(45, 360);
this->addChild(l1);
l2->setPosition(1280-45, 360);
this->addChild(l2);
return true;
}
示例9: addChild
void PopupLayer::setPublishLotteryContext(Size size)
{
//添加转盘
m_turnBg = Sprite::create("LotteryTurn/turn_bg.png");
m_turnBg->setPosition(Vec2(winSize.width / 2, winSize.height / 2));
addChild(m_turnBg);
//添加指针
auto arrNor = Sprite::create("LotteryTurn/turn_arrow.png");
arrNor->setPosition(Vec2(winSize.width / 2, winSize.height * 0.557));
arrNor->setScale(0.5);
addChild(arrNor);
//添加中奖之后的简单界面
awardLayer = LayerColor::create(Color4B(0, 0, 0, 100));
awardLayer->setPosition(Point::ZERO);
awardLayer->setTag(100);
addChild(awardLayer, 10);
awardLayer->setVisible(false);
addPlayersInfo(size);
}
示例10: init
bool HelloWorld::init()
{
if (!LayerColor::initWithColor(Color4B(255, 255, 255, 255)))
{
return false;
}
tmap = TMXTiledMap::create("TileMaps/TestDesert.tmx");
this->addChild(tmap, 0, 11);
auto objects = tmap->getObjectGroup("Objects");
ValueMap spawnPoint = objects->getObject("SpawnPoint");
int x = spawnPoint["x"].asInt();
int y = spawnPoint["y"].asInt();
dragonPosition = Vec2(x, y);
this->createDragon();
return true;
}
示例11: init
bool PRKitDemoScene::init()
{
if(!Layer::init())
{
return false;
}
auto color_bg = LayerColor::create(Color4B(125, 125, 125, 125));
addChild(color_bg);
auto demo_info_label = Label::create(demo_info(), "Helvetica", 25, Size(500, 200), TextHAlignment::LEFT);
this->addChild(demo_info_label);
demo_info_label->setAnchorPoint(Point(0.0f, 1.0f));
demo_info_label->setColor(Color3B(255, 255, 255));
demo_info_label->setPosition(VisibleRect::leftTop() + Point(60, -60));
auto backMenuItem = MenuItemImage::create("backNormal.png", "backSelected.png", CC_CALLBACK_1(PRKitDemoScene::backCallback, this));
auto restartMenuItem = MenuItemImage::create("refreshNormal.png", "refreshSelected.png", CC_CALLBACK_1(PRKitDemoScene::restartCallback, this));
restartMenuItem->setPosition(VisibleRect::rightTop() + Point(-200, -80));
backMenuItem->setPosition(restartMenuItem->getPosition() + Point(90, 0));
auto menu = Menu::create(backMenuItem, restartMenuItem, NULL);
menu->setPosition(Point::ZERO);
this->addChild(menu, 300);
Vector2dVector polygonPoints;
polygonPoints.push_back(Vector2d(100, 100));
polygonPoints.push_back(Vector2d(200, 100));
polygonPoints.push_back(Vector2d(300, 200));
polygonPoints.push_back(Vector2d(400, 300));
polygonPoints.push_back(Vector2d(500, 500));
Texture2D *texture = Director::getInstance()->getTextureCache()->addImage("pattern1.png");
PRFilledPolygon *filledPolygon = PRFilledPolygon::filledPolygonWithPointsAndTexture(polygonPoints, texture);
addChild(filledPolygon);
return true;
}
示例12: BaseTest
TextLayer::TextLayer(void)
: BaseTest()
{
LayerColor *background = LayerColor::create( Color4B(32,128,32,255) );
this->addChild(background,-20);
_gridNodeTarget = NodeGrid::create();
auto effect = getAction();
_gridNodeTarget->runAction(effect);
addChild(_gridNodeTarget, 0, kTagBackground);
auto bg = Sprite::create(s_back3);
_gridNodeTarget->addChild(bg, 0);
// bg->setAnchorPoint( Vec2::ZERO );
bg->setPosition(VisibleRect::center());
auto grossini = Sprite::create(s_pathSister2);
_gridNodeTarget->addChild(grossini, 1);
grossini->setPosition( Vec2(VisibleRect::left().x+VisibleRect::getVisibleRect().size.width/3,VisibleRect::center().y) );
auto sc = ScaleBy::create(2, 5);
auto sc_back = sc->reverse();
grossini->runAction( RepeatForever::create(Sequence::create(sc, sc_back, NULL) ) );
auto tamara = Sprite::create(s_pathSister1);
_gridNodeTarget->addChild(tamara, 1);
tamara->setPosition( Vec2(VisibleRect::left().x+2*VisibleRect::getVisibleRect().size.width/3,VisibleRect::center().y) );
auto sc2 = ScaleBy::create(2, 5);
auto sc2_back = sc2->reverse();
tamara->runAction( RepeatForever::create(Sequence::create(sc2, sc2_back, NULL)) );
auto label = Label::createWithTTF((effectsList[actionIdx]).c_str(), "fonts/Marker Felt.ttf", 32);
label->setPosition( Vec2(VisibleRect::center().x,VisibleRect::top().y-80) );
addChild(label);
label->setTag( kTagLabel );
schedule( schedule_selector(TextLayer::checkAnim) );
}
示例13: init
bool PauseLayer::init()
{
if (!Layer::init()) {
return false;
}
const Size &size=Director::getInstance()->getWinSize();
//灰色背景
LayerColor* backLayerColor = LayerColor::create(Color4B(25, 25, 25, 125));
this->addChild(backLayerColor);
// 暂停
MenuItemFont *menuItemPause = MenuItemFont::create("Continue", CC_CALLBACK_1(PauseLayer::menuContinueCallBack, this));
menuItemPause->setPosition(Point(size.width / 2 - 100, size.height / 2));
// 重新开始
MenuItemFont *menuItemRestart = MenuItemFont::create("Restart", CC_CALLBACK_1(PauseLayer::menuRestartCallBack, this));
menuItemRestart->setPosition(Point(size.width / 2 + 100, size.height / 2));
Menu *menu=Menu::create(menuItemPause, menuItemRestart, NULL);
menu->setPosition(Point::ZERO);
this->addChild(menu);
//不声明 不定义 ontouchbegan的使用方法
// auto callback = [](Touch * ,Event *)
// {
// return true;
// };
// auto listener = EventListenerTouchOneByOne::create();
// listener->onTouchBegan = callback;
// listener->setSwallowTouches(true);
// _eventDispatcher->addEventListenerWithSceneGraphPriority(listener,this);
EventListenerTouchOneByOne* listener = EventListenerTouchOneByOne::create();
listener->onTouchBegan = CC_CALLBACK_2(PauseLayer::onTouchBegan, this);
listener->setSwallowTouches(true);
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
return true;
}
示例14: init
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
if ( !LayerColor::initWithColor(Color4B(255,255,255,255)) )
{
return false;
}
/////////////////////////////
auto pMenuItem = MenuItemFont::create("Action", CC_CALLBACK_1(HelloWorld::doAction, this));
pMenuItem->setColor(Color3B::BLACK);
auto pMenu = Menu::create(pMenuItem, nullptr);
pMenu->setPosition(Vec2(240, 50));
this->addChild(pMenu);
pBall = Sprite::create("Images/r1.png");
pBall->setPosition(Vec2(50, 100));
pBall->setScale(0.7f);
this->addChild(pBall);
pMan = Sprite::create("Images/grossini.png");
pMan->setPosition(Vec2(50, 150));
pMan->setScale(0.5f);
this->addChild(pMan);
pWomen1 = Sprite::create("Images/grossinis_sister1.png");
pWomen1->setPosition(Vec2(50, 220));
pWomen1->setScale(0.5f);
this->addChild(pWomen1);
pWomen2 = Sprite::create("Images/grossinis_sister2.png");
pWomen2->setPosition(Vec2(50, 280));
pWomen2->setScale(0.5f);
this->addChild(pWomen2);
return true;
}
示例15: setTouchEnabled
// 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())
{
setTouchEnabled(true);
// ask director the the window size
Size 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(Point(size.width/2, size.height/2));
layer->setAnchorPoint(Point(0.5f, 0.5f));
layer->ignoreAnchorPointForPosition(false);
addChild(layer, -1-i);
}
// create and initialize a Label
LabelTTF *label = LabelTTF::create("Hello World", "Marker Felt", 64);
MenuItem *item1 = MenuItemFont::create("restart", CC_CALLBACK_1(Bug914Layer::restart, this));
Menu *menu = Menu::create(item1, NULL);
menu->alignItemsVertically();
menu->setPosition(Point(size.width/2, 100));
addChild(menu);
// position the label on the center of the screen
label->setPosition(Point( size.width /2 , size.height/2 ));
// add the label as a child to this Layer
addChild(label);
return true;
}
return false;
}