本文整理汇总了C++中LabelTTF::setColor方法的典型用法代码示例。如果您正苦于以下问题:C++ LabelTTF::setColor方法的具体用法?C++ LabelTTF::setColor怎么用?C++ LabelTTF::setColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LabelTTF
的用法示例。
在下文中一共展示了LabelTTF::setColor方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initWithSubTest
////////////////////////////////////////////////////////
//
// SpriteMainScene
//
////////////////////////////////////////////////////////
void SpriteMainScene::initWithSubTest(int asubtest, int nNodes)
{
//srandom(0);
subtestNumber = asubtest;
_subTest = new SubTest;
_subTest->initWithSubTest(asubtest, this);
Size s = Director::sharedDirector()->getWinSize();
lastRenderedCount = 0;
quantityNodes = 0;
MenuItemFont::setFontSize(65);
MenuItemFont *decrease = MenuItemFont::create(" - ", CC_CALLBACK_1(SpriteMainScene::onDecrease, this));
decrease->setColor(ccc3(0,200,20));
MenuItemFont *increase = MenuItemFont::create(" + ", CC_CALLBACK_1(SpriteMainScene::onIncrease, this));
increase->setColor(ccc3(0,200,20));
Menu *menu = Menu::create(decrease, increase, NULL);
menu->alignItemsHorizontally();
menu->setPosition(ccp(s.width/2, s.height-65));
addChild(menu, 1);
LabelTTF *infoLabel = LabelTTF::create("0 nodes", "Marker Felt", 30);
infoLabel->setColor(ccc3(0,200,20));
infoLabel->setPosition(ccp(s.width/2, s.height-90));
addChild(infoLabel, 1, kTagInfoLayer);
// add menu
SpriteMenuLayer* pMenu = new SpriteMenuLayer(true, TEST_COUNT, s_nSpriteCurCase);
addChild(pMenu, 1, kTagMenuLayer);
pMenu->release();
// Sub Tests
MenuItemFont::setFontSize(32);
Menu* pSubMenu = Menu::create();
for (int i = 1; i <= 9; ++i)
{
char str[10] = {0};
sprintf(str, "%d ", i);
MenuItemFont* itemFont = MenuItemFont::create(str, CC_CALLBACK_1(SpriteMainScene::testNCallback, this));
itemFont->setTag(i);
pSubMenu->addChild(itemFont, 10);
if( i<= 3)
itemFont->setColor(ccc3(200,20,20));
else if(i <= 6)
itemFont->setColor(ccc3(0,200,20));
else
itemFont->setColor(ccc3(0,20,200));
}
pSubMenu->alignItemsHorizontally();
pSubMenu->setPosition(ccp(s.width/2, 80));
addChild(pSubMenu, 2);
// add title label
LabelTTF *label = LabelTTF::create(title().c_str(), "Arial", 40);
addChild(label, 1);
label->setPosition(ccp(s.width/2, s.height-32));
label->setColor(ccc3(255,255,40));
while(quantityNodes < nNodes)
onIncrease(this);
}
示例2: creatScene
Scene* SGDramaSceneSelectScene::creatScene(const char* hero_name, const char* content, int* ret_add)
{
Scene* scene = Scene::create();
SGDramaSceneSelectScene* select_layer = SGDramaSceneSelectScene::create();
Size win_size = Director::getInstance()->getWinSize();
RenderTexture* render_texture = RenderTexture::create(win_size.width, win_size.height);
render_texture->begin();
Director::getInstance()->getRunningScene()->visit();
render_texture->end();
render_texture->setPosition(Vec2(win_size.width/2, win_size.height/2));
select_layer->addChild(render_texture);
// Create the select dialog window
// step 1: create the dialog window backgound texture;
Sprite* dialog_win = Sprite::create(SELECT_WINDOW_BACKGROUND);
Size dialog_size(win_size.width * 0.666f, win_size.height * 0.1928f);
dialog_win->setTextureRect(Rect(0, 0, dialog_size.width, dialog_size.height));
Texture2D::TexParams params = { GL_LINEAR, GL_LINEAR, GL_REPEAT, GL_REPEAT };
dialog_win->getTexture()->setTexParameters(params);
dialog_win->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
dialog_win->setPosition(Vec2(win_size.width/2, win_size.height/2));
// step 2: create hero face image;
std::string hero_face_res = SG_HERO_FACE_RES_PATH;
hero_face_res.append(SGHeroResourceUtils::getInstance()->getHeroResObj(hero_name)->res_name);
hero_face_res.append(".png");
Sprite* face = Sprite::create(hero_face_res);
face->setPosition(Vec2(dialog_size.width * 0.1f ,dialog_size.height/2));
dialog_win->addChild(face);
// step 3: create dialog content background
LayerColor* content_bg_layer = LayerColor::create(Color4B::WHITE, dialog_size.width * 0.75f ,dialog_size.height * 0.6667f);
content_bg_layer->setPosition(Vec2(dialog_size.width * 0.2333f ,dialog_size.height * 0.0714f));
Size content_bg_layer_size = content_bg_layer->getContentSize();
dialog_win->addChild(content_bg_layer);
// step 4: create each menu item
std::string select_items = content;
std::string::size_type start_pos = 0;
std::string::size_type pos = 0;
std::string separator = "\\n";
std::string null_str = " ";
Menu* select_menu;
int menu_size = 0;
MenuItemLabel *menu_item1, *menu_item2, *menu_item3;
while ((pos = select_items.find(separator, start_pos)) != std::string::npos){
//speak.replace( pos, srcLen, des_str );
std::string one_item_content = select_items.substr(start_pos, pos - start_pos);
//one_item_content.replace(one_item_content.find(separator, 0), separator.size(), null_str);
LabelTTF* label = LabelTTF::create(one_item_content, TEXT_FONT_NAME, TEXT_FONT_SIZE);
label->setColor(Color3B::BLACK);
menu_size++;
switch (menu_size)
{
case 1:
menu_item1 = MenuItemLabel::create(label, CC_CALLBACK_1(SGDramaSceneSelectScene::menuItem1Callback, select_layer));
break;
case 2:
menu_item2 = MenuItemLabel::create(label, CC_CALLBACK_1(SGDramaSceneSelectScene::menuItem2Callback, select_layer));
break;
case 3:
menu_item3 = MenuItemLabel::create(label, CC_CALLBACK_1(SGDramaSceneSelectScene::menuItem3Callback, select_layer));
default:
break;
}
start_pos = pos + separator.size();
}
switch (menu_size)
{
case 2:
select_menu = Menu::create(menu_item1, menu_item2, NULL);
break;
case 3:
select_menu = Menu::create(menu_item1, menu_item2, menu_item3, NULL);
break;
default:
break;
}
select_menu->alignItemsVertically();
select_menu->setPosition(content_bg_layer_size.width/2, content_bg_layer_size.height/2);
content_bg_layer->addChild(select_menu);
select_layer->addChild(dialog_win);
scene->addChild(select_layer);
select_layer->__ret = ret_add;
return scene;
}
示例3: initWithSubTest
////////////////////////////////////////////////////////
//
// ParticleMainScene
//
////////////////////////////////////////////////////////
void ParticleMainScene::initWithSubTest(int asubtest, int particles)
{
//srandom(0);
subtestNumber = asubtest;
Size s = Director::getInstance()->getWinSize();
lastRenderedCount = 0;
quantityParticles = particles;
MenuItemFont::setFontSize(65);
MenuItemFont *decrease = MenuItemFont::create(" - ", [&](Object *sender) {
quantityParticles -= kNodesIncrease;
if( quantityParticles < 0 )
quantityParticles = 0;
updateQuantityLabel();
createParticleSystem();
});
decrease->setColor(Color3B(0,200,20));
MenuItemFont *increase = MenuItemFont::create(" + ", [&](Object *sender) {
quantityParticles += kNodesIncrease;
if( quantityParticles > kMaxParticles )
quantityParticles = kMaxParticles;
updateQuantityLabel();
createParticleSystem();
});
increase->setColor(Color3B(0,200,20));
Menu *menu = Menu::create(decrease, increase, NULL);
menu->alignItemsHorizontally();
menu->setPosition(Point(s.width/2, s.height/2+15));
addChild(menu, 1);
LabelTTF *infoLabel = LabelTTF::create("0 nodes", "Marker Felt", 30);
infoLabel->setColor(Color3B(0,200,20));
infoLabel->setPosition(Point(s.width/2, s.height - 90));
addChild(infoLabel, 1, kTagInfoLayer);
// particles on stage
LabelAtlas *labelAtlas = LabelAtlas::create("0000", "fps_images.png", 12, 32, '.');
addChild(labelAtlas, 0, kTagLabelAtlas);
labelAtlas->setPosition(Point(s.width-66,50));
// Next Prev Test
ParticleMenuLayer* menuLayer = new ParticleMenuLayer(true, TEST_COUNT, s_nParCurIdx);
addChild(menuLayer, 1, kTagMenuLayer);
menuLayer->release();
// Sub Tests
MenuItemFont::setFontSize(40);
Menu* pSubMenu = Menu::create();
for (int i = 1; i <= 6; ++i)
{
char str[10] = {0};
sprintf(str, "%d ", i);
MenuItemFont* itemFont = MenuItemFont::create(str, CC_CALLBACK_1(ParticleMainScene::testNCallback, this));
itemFont->setTag(i);
pSubMenu->addChild(itemFont, 10);
if (i <= 3)
{
itemFont->setColor(Color3B(200,20,20));
}
else
{
itemFont->setColor(Color3B(0,200,20));
}
}
pSubMenu->alignItemsHorizontally();
pSubMenu->setPosition(Point(s.width/2, 80));
addChild(pSubMenu, 2);
LabelTTF *label = LabelTTF::create(title().c_str(), "Arial", 40);
addChild(label, 1);
label->setPosition(Point(s.width/2, s.height-32));
label->setColor(Color3B(255,255,40));
updateQuantityLabel();
createParticleSystem();
schedule(schedule_selector(ParticleMainScene::step));
}