本文整理汇总了C++中MenuItemFont::setTag方法的典型用法代码示例。如果您正苦于以下问题:C++ MenuItemFont::setTag方法的具体用法?C++ MenuItemFont::setTag怎么用?C++ MenuItemFont::setTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MenuItemFont
的用法示例。
在下文中一共展示了MenuItemFont::setTag方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initNavigator
void GamePlayScene::initNavigator() {
MenuItemFont *menuTitle = MenuItemFont::create(Constant::MENU_PLAY, CC_CALLBACK_1(GamePlayScene::navigatorCallback, this));
menuTitle->setFontName(Constant::FONT);
menuTitle->setFontSize(64);
menuTitle->setVisible(false);
MenuItemFont *back = MenuItemFont::create(Constant::MENU_BACK, CC_CALLBACK_1(GamePlayScene::navigatorCallback, this));
back->setFontName(Constant::FONT);
back->setFontSize(64);
back->setTag(Constant::MENU_BACK_TAG);
MenuItemFont *start = MenuItemFont::create(Constant::MENU_START, CC_CALLBACK_1(GamePlayScene::navigatorCallback, this));
start->setFontName(Constant::FONT);
start->setFontSize(64);
start->setTag(Constant::MENU_START_TAG);
Menu *menu = Menu::create(back, start, NULL);
Size visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();
back->setPosition(Vec2(origin.x + visibleSize.width - back->getContentSize().width / 2,
origin.y + back->getContentSize().height / 2));
start->setPosition(Vec2(origin.x + start->getContentSize().width / 2,
origin.y + back->getContentSize().height / 2));
menu->setPosition(Vec2::ZERO);
addChild(menu);
}
示例2: init
bool TMenu::init()
{
Layer::init();
Menu * menu = Menu::create();
addChild(menu);
for (int i = 0; i < sizeof(title) / sizeof(*title); ++i)
{
MenuItemFont * item = MenuItemFont::create(title[i], [](Ref * sender){
MenuItem * item = (MenuItem *)sender;
int i = item->getTag() - 1000;
Layer * l = NULL;
if (title[i] == "T01CPP11") l = T01CPP11::create();
else if (title[i] == "T02Vector") l = T02Vector::create();
else if (title[i] == "T03Map") l = T03Map::create();
else if (title[i] == "T04Label") l = T04Label::create();
else if (title[i] == "T05Touch") l = T05Touch::create();
else if (title[i] == "T06Box2D") l = T06Box2D::create();
else if (title[i] == "T07PhysicsWorld") l = T07PhysicsWorld::create();
else if (title[i] == "T08RayCast") l = T08RayCast::create();
else if (title[i] == "T09Joint") l = T09Joint::create();
else if (title[i] == "T10MultiShapes") l = T10MultiShapes::create();
else if (title[i] == "T11FlyppyBird") l = T11FlyppyBird::create();
if (l != NULL)
{
TBack * b = TBack::create();
//Scene * s = Scene::create();
Scene * s = Scene::createWithPhysics(); // 3.x ÎïÀíÊÀ½ç
PhysicsWorld * world = s->getPhysicsWorld();
world->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL);
s->addChild(b);
s->addChild(l);
Director::getInstance()->pushScene(s);
}
});
menu->addChild(item);
item->setTag(1000 + i);
}
menu->alignItemsVertically();
// ´¥Ãþ
auto ev = EventListenerTouchOneByOne::create();
//ev->onTouchBegan = std::bind(&TMenu::touchBegan, this, std::placeholders::_1, std::placeholders::_2);
ev->onTouchBegan = CC_CALLBACK_2(TMenu::touchBegan, this);
ev->onTouchMoved = [&](Touch * touch, Event *){
setPositionY(getPositionY() + touch->getDelta().y);
};
_eventDispatcher->addEventListenerWithSceneGraphPriority(ev, this);
return true;
}
示例3: onLoadScene
void MenuScene::onLoadScene()
{
m_vMenuItems.push_back("Basic Test");
Size tContainerSize = Size(700, 100 * m_vMenuItems.size());
Layer* pScrollViewContainer = Layer::create();
pScrollViewContainer->setPosition(Point::ZERO);
pScrollViewContainer->setContentSize(tContainerSize);
m_pScrollView = ScrollView::create(Size(700, 640));
m_pScrollView->ignoreAnchorPointForPosition(false);
m_pScrollView->setPosition(CCPoint(480, 320));
m_pScrollView->setContainer(pScrollViewContainer);
addChild(m_pScrollView);
Vector<MenuItem *> vet;
float height = tContainerSize.height;
unsigned int i = 0;
unsigned int end = m_vMenuItems.size();
for(; i < end; ++i )
{
MenuItemFont* pFont = MenuItemFont::create(m_vMenuItems[i].c_str());
pFont->setCallback(CC_CALLBACK_1(MenuScene::onClick,this));
pFont->setFontSizeObj(45.0f);
pFont->setPosition(Point(700 / 2, height - 100 / 2));
pFont->setTag(i + 1);
vet.pushBack(pFont);
height -= 100;
}
Menu* pMenu = Menu::createWithArray(vet);
pMenu->setPosition(Point(0,0));
pScrollViewContainer->addChild(pMenu);
m_pScrollView->setContentOffset(Point(0, -(tContainerSize.height - 640)));
}
示例4: init
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !Layer::init() )
{
return false;
}
Size visibleSize = Director::getInstance()->getVisibleSize();
Point origin = Director::getInstance()->getVisibleOrigin();
/////////////////////////////
// 2. add a menu item with "X" image, which is clicked to quit the program
// you may modify it.
// add a "close" icon to exit the progress. it's an autorelease object
MenuItemImage *pCloseItem = MenuItemImage::create(
"CloseNormal.png",
"CloseSelected.png",
CC_CALLBACK_1(HelloWorld::menuCloseCallback, this));
pCloseItem->setPosition(Point(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2 ,
origin.y + pCloseItem->getContentSize().height/2));
// create menu, it's an autorelease object
Menu* pMenu = Menu::create(pCloseItem, NULL);
pMenu->setPosition(Point::ZERO);
this->addChild(pMenu, 1);
Point beginPos = Point(origin.x + visibleSize.width / 2, origin.y + visibleSize.height - 50);
float step = 60.0f;
int nCaseCount = sizeof(g_testCases) / sizeof(std::string);
for (int i = 0; i < nCaseCount; ++i) {
std::string caseName = g_testCases[i];
MenuItemFont *pItem = MenuItemFont::create(caseName.c_str(), CC_CALLBACK_1(HelloWorld::menuCallback, this));
pItem->setTag(i);
pItem->setPosition(Point(beginPos.x, beginPos.y - i * step));
pMenu->addChild(pItem);
}
return true;
}
示例5: initWithSubTest
void SpriteMainScene::initWithSubTest(int asubtest, int nNodes)
{
//srandom(0);
subtestNumber = asubtest;
_subTest = new SubTest;
_subTest->initWithSubTest(asubtest, this);
auto s = Director::getInstance()->getWinSize();
lastRenderedCount = 0;
quantityNodes = 0;
MenuItemFont::setFontSize(65);
auto decrease = MenuItemFont::create(" - ", CC_CALLBACK_1(SpriteMainScene::onDecrease, this));
decrease->setColor(Color3B(0,200,20));
auto increase = MenuItemFont::create(" + ", CC_CALLBACK_1(SpriteMainScene::onIncrease, this));
increase->setColor(Color3B(0,200,20));
auto menu = Menu::create(decrease, increase, NULL);
menu->alignItemsHorizontally();
menu->setPosition(Point(s.width/2, s.height-65));
addChild(menu, 1);
auto 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);
// add menu
auto menuLayer = new SpriteMenuLayer(true, TEST_COUNT, SpriteMainScene::_s_nSpriteCurCase);
addChild(menuLayer, 1, kTagMenuLayer);
menuLayer->release();
/**
* auto test menu
*/
auto menuAutoTest = Menu::create();
menuAutoTest->setPosition( Point::ZERO );
MenuItemFont::setFontName("Arial");
MenuItemFont::setFontSize(24);
MenuItemFont* autoTestItem = NULL;
if (SpriteMainScene::_s_autoTest)
{
autoTestItem = MenuItemFont::create("Auto Test On",CC_CALLBACK_1(SpriteMainScene::onAutoTest, this));
}
else
{
autoTestItem = MenuItemFont::create("Auto Test Off",CC_CALLBACK_1(SpriteMainScene::onAutoTest, this));
}
autoTestItem->setTag(1);
autoTestItem->setPosition(Point( s.width - 90, s.height / 2));
menuAutoTest->addChild(autoTestItem);
addChild( menuAutoTest, 3, kTagAutoTestMenu );
// Sub Tests
MenuItemFont::setFontSize(28);
auto subMenu = Menu::create();
for (int i = 1; i <= 13; ++i)
{
char str[10] = {0};
sprintf(str, "%d ", i);
auto itemFont = MenuItemFont::create(str, CC_CALLBACK_1(SpriteMainScene::testNCallback, this));
itemFont->setTag(i);
subMenu->addChild(itemFont, 10);
if( i<= 4)
itemFont->setColor(Color3B(200,20,20));
else if(i <= 8)
itemFont->setColor(Color3B(0,200,20));
else if( i<=12)
itemFont->setColor(Color3B(0,20,200));
else
itemFont->setColor(Color3B::GRAY);
}
subMenu->alignItemsHorizontally();
subMenu->setPosition(Point(s.width/2, 80));
addChild(subMenu, 2);
// add title label
auto label = LabelTTF::create(title(), "Arial", 40);
addChild(label, 1);
label->setPosition(Point(s.width/2, s.height-32));
label->setColor(Color3B(255,255,40));
// subtitle
std::string strSubtitle = subtitle();
if( ! strSubtitle.empty() )
{
auto l = LabelTTF::create(strSubtitle.c_str(), "Thonburi", 16);
addChild(l, 9999);
l->setPosition( Point(VisibleRect::center().x, VisibleRect::top().y - 60) );
}
while(quantityNodes < nNodes)
onIncrease(this);
//.........这里部分代码省略.........
示例6: init
bool TestFragmentEffect::init()
{
if ( !TestBase::init() )
{
return false;
}
//都是菜单设置,可以不看
MenuItemFont* MIF0 = MenuItemFont::create("ES_NONE");
MIF0->setColor(Color3B::RED);
MIF0->setTag(0);
MenuItemFont* MIF1 = MenuItemFont::create("ES_BLACK_AND_WHITE");
MIF1->setColor(Color3B::RED);
MIF1->setTag(0);
MenuItemFont* MIF2 = MenuItemFont::create("ES_OLD_PHOTOS");
MIF2->setColor(Color3B::RED);
MIF2->setTag(0);
MenuItemFont* MIF3 = MenuItemFont::create("ES_INVERT");
MIF3->setColor(Color3B::RED);
MIF3->setTag(0);
MenuItemFont* MIF4 = MenuItemFont::create("ES_BURNS");
MIF4->setColor(Color3B::RED);
MIF4->setTag(0);
MenuItemFont* MIF5 = MenuItemFont::create("ES_POISONING");
MIF5->setColor(Color3B::RED);
MIF5->setTag(0);
MenuItemFont* MIF6 = MenuItemFont::create("ES_COLD");
MIF6->setColor(Color3B::RED);
MIF6->setTag(0);
MenuItemFont* MIF7 = MenuItemFont::create("ES_USER_DEFINED");
MIF7->setColor(Color3B::RED);
MIF7->setTag(0);
m_sel = MenuItemToggle::createWithCallback(CC_CALLBACK_1(TestFragmentEffect::toggleCallback,this),MIF0,MIF1,MIF2,MIF3,MIF4,MIF5,MIF6,MIF7,NULL);
m_sel->setTag(0);
m_sel->setAnchorPoint(Vec2(0.5f,1.0f));
m_sel->setPosition(Vec2(m_visibleOrigin.x + m_visibleSize.width / 2,
m_visibleOrigin.y + m_visibleSize.height - 7));
MenuItemImage* last = MenuItemImage::create("FragmentEffect/lastNor.png","FragmentEffect/lastCli.png","",CC_CALLBACK_1(TestFragmentEffect::toggleCallback,this));
last->setTag(-1);
last->setAnchorPoint(Vec2(0.5f,1.0f));
last->setPosition(Vec2(m_visibleOrigin.x + m_visibleSize.width / 10 * 1,
m_visibleOrigin.y + m_visibleSize.height));
MenuItemImage* next = MenuItemImage::create("FragmentEffect/nextNor.png","FragmentEffect/nextCli.png","",CC_CALLBACK_1(TestFragmentEffect::toggleCallback,this));
next->setTag(1);
next->setAnchorPoint(Vec2(0.5f,1.0f));
next->setPosition(Vec2(m_visibleOrigin.x + m_visibleSize.width / 10 * 9,
m_visibleOrigin.y + m_visibleSize.height));
MenuItemFont* UDF = MenuItemFont::create("goto ES_USER_DEFINED",CC_CALLBACK_1(TestFragmentEffect::gotoUserDefine,this));
UDF->setColor(Color3B::RED);
UDF->setTag(0);
UDF->setPosition(Vec2(m_visibleOrigin.x + m_visibleSize.width / 2,
m_visibleOrigin.y + m_visibleSize.height - 50.0f));
Menu* pMenu = Menu::create(m_sel,last,next,UDF,NULL);
pMenu->setPosition(Vec2::ZERO);
this->addChild(pMenu, 1);
m_bgSprite = Sprite::create("FragmentEffect/HelloWorld.png");
m_bgSprite->setPosition(Vec2(m_visibleOrigin.x + m_visibleSize.width / 2,
m_visibleOrigin.y + m_visibleSize.height / 2));
this->addChild(m_bgSprite, 0);
//加载骨骼动画
ArmatureDataManager::getInstance()->addArmatureFileInfo("FragmentEffect/Hero0.png","FragmentEffect/Hero0.plist","FragmentEffect/Hero.ExportJson");
m_armature = Armature::create("Hero");
m_armature->getAnimation()->playWithIndex(0);
m_armature->setPosition(Vec2(m_visibleOrigin.x+m_visibleSize.width/2, 0.0f));
m_armature->setAnchorPoint(Vec2(0.5f,0.0f));
this->addChild(m_armature,1);
//淡出淡入这样的动作依然可以使用
m_armature->runAction(Sequence::create(FadeOut::create(0.5f),FadeIn::create(0.5f),0));
//就这几句是设置效果的,toggleCallback 和 gotoUserDefine方法里面也有
m_indexSprite = FragmentEffect::getInstance()->addEffectNode(m_bgSprite); //m_indexSprite接收返回的序号,setEffect 和 getEffectSelect 的时候使用
m_indexArmature = FragmentEffect::getInstance()->addEffectNode(m_armature); //m_indexArmature接收返回的序号,setEffect 和 getEffectSelect 的时候使用
float f[] = {
0.5f,0.0f,0.0f,0.0f,
0.0f,0.5f,0.0f,0.0f,
0.0f,0.0f,0.5f,0.0f,
0.0f,0.0f,0.0f,0.5f
};
FragmentEffect::getInstance()->addEffectMatrix(Mat4(f));//增加自定义特效矩阵,序号从 ES_USER_DEFINED 开始增加
return true;
}
示例7: createLevelEditorUI
void UI::createLevelEditorUI()
{
Size visibleSize = Director::getInstance()->getVisibleSize();
auto labelMenuTitle = LabelTTF::create("Level Editor", "Segoe UI", 12);
labelMenuTitle->setPosition(35.0f, visibleSize.height - 40.0f);
m_pLevelEditor->addChild(labelMenuTitle);
MenuItemImage* sidebarBackground = MenuItemImage::create("Resources/pictures/generic/ui_background.png", "ui_background.png", CC_CALLBACK_0(UI::nullCallback, this));
sidebarBackground->setPosition(100.0f, visibleSize.height * 0.5f);
sidebarBackground->setScale(200, visibleSize.height);
MenuItemFont* addTextureObject = MenuItemFont::create("add texture", CC_CALLBACK_1(LevelEditor::addTextureObjectCallback, pLevelEditor));
addTextureObject->setFontNameObj("Arial");
addTextureObject->setFontSizeObj(30);
addTextureObject->setPosition(80.0f, visibleSize.height - 80.0f);
MenuItemFont* addGroundObject = MenuItemFont::create("add ground", CC_CALLBACK_1(LevelEditor::addGroundObjectCallback, pLevelEditor));
addGroundObject->setFontNameObj("Arial");
addGroundObject->setFontSizeObj(30);
addGroundObject->setPosition(80.0f, visibleSize.height - 120.0f);
MenuItemFont* addNutObject = MenuItemFont::create("add nut", CC_CALLBACK_1(LevelEditor::addNutObjectCallback, pLevelEditor));
addNutObject->setFontNameObj("Arial");
addNutObject->setFontSizeObj(30);
addNutObject->setPosition(80.0f, visibleSize.height - 160.0f);
MenuItemFont* addCrystalObject = MenuItemFont::create("add crystal", CC_CALLBACK_1(LevelEditor::addCrystalObjectCallback, pLevelEditor));
addCrystalObject->setFontNameObj("Arial");
addCrystalObject->setFontSizeObj(30);
addCrystalObject->setPosition(80.0f, visibleSize.height - 200.0f);
MenuItemFont* addAirObject = MenuItemFont::create("add aircurrent", CC_CALLBACK_1(LevelEditor::addAirObjectCallback, pLevelEditor));
addAirObject->setFontNameObj("Arial");
addAirObject->setFontSizeObj(30);
addAirObject->setPosition(80.0f, visibleSize.height - 240.0f);
MenuItemFont* changeLayerObject = MenuItemFont::create("mainLayer", CC_CALLBACK_0(LevelEditor::changeLayerCallback, pLevelEditor));
changeLayerObject->setFontNameObj("Arial");
changeLayerObject->setFontSizeObj(30);
changeLayerObject->setPosition(73.0f, visibleSize.height - 280.0f);
changeLayerObject->setTag(111);
MenuItemFont* toggleGrid = MenuItemFont::create("snap to grid", CC_CALLBACK_0(LevelEditor::toggleGridCallback, pLevelEditor));
toggleGrid->setFontNameObj("Arial");
toggleGrid->setFontSizeObj(30);
toggleGrid->setPosition(80.0f, visibleSize.height - 320.0f);
toggleGrid->setTag(112);
MenuItemFont* toggleSelectionMode = MenuItemFont::create("selection", CC_CALLBACK_0(LevelEditor::toggleSelectionMode, pLevelEditor));
toggleSelectionMode->setFontNameObj("Arial");
toggleSelectionMode->setFontSizeObj(30);
toggleSelectionMode->setPosition(80.0f, visibleSize.height - 360.0f);
toggleSelectionMode->setTag(113);
MenuItemFont* saveLevelObject = MenuItemFont::create("save level", CC_CALLBACK_0(LevelEditor::saveLevelCallback, pLevelEditor));
saveLevelObject->setFontNameObj("Arial");
saveLevelObject->setFontSizeObj(30);
saveLevelObject->setPosition(70.0f, visibleSize.height - 400.0f);
MenuItemFont* mainMenuObject = MenuItemFont::create("Mainmenu", CC_CALLBACK_0(LevelEditor::mainMenuCallback, pLevelEditor));
mainMenuObject->setFontNameObj("Arial");
mainMenuObject->setFontSizeObj(30);
mainMenuObject->setPosition(70.0f, visibleSize.height - 440.0f);
auto menu = Menu::create(addTextureObject, addGroundObject, addNutObject, addCrystalObject, addAirObject, changeLayerObject, toggleSelectionMode, saveLevelObject, toggleGrid, mainMenuObject, NULL);
auto menuBackground = Menu::create(sidebarBackground, NULL);
menuBackground->setPosition(0, 0);
menu->setPosition(0, 0);
m_pLevelEditor->addChild(menu);
m_pLevelEditor->addChild(menuBackground, -10);
pLevelEditor->MainMenu = menu;
}
示例8: initWithSubTest
void LabelMainScene::initWithSubTest(int nodes)
{
//srandom(0);
auto s = Director::getInstance()->getWinSize();
_lastRenderedCount = 0;
_quantityNodes = 0;
_accumulativeTime = 0.0f;
_labelContainer = Layer::create();
addChild(_labelContainer);
MenuItemFont::setFontSize(65);
auto decrease = MenuItemFont::create(" - ", CC_CALLBACK_1(LabelMainScene::onDecrease, this));
decrease->setColor(Color3B(0,200,20));
auto increase = MenuItemFont::create(" + ", CC_CALLBACK_1(LabelMainScene::onIncrease, this));
increase->setColor(Color3B(0,200,20));
auto menu = Menu::create(decrease, increase, NULL);
menu->alignItemsHorizontally();
menu->setPosition(Vec2(s.width/2, s.height-65));
addChild(menu, 1);
auto infoLabel = Label::createWithTTF("0 nodes", "fonts/Marker Felt.ttf", 30);
infoLabel->setColor(Color3B(0,200,20));
infoLabel->setPosition(Vec2(s.width/2, s.height-90));
addChild(infoLabel, 1, kTagInfoLayer);
// add menu
auto menuLayer = new LabelMenuLayer(true, TEST_COUNT, LabelMainScene::_s_labelCurCase);
addChild(menuLayer, 1, kTagMenuLayer);
menuLayer->release();
/**
* auto test menu
*/
auto menuAutoTest = Menu::create();
menuAutoTest->setPosition( Vec2::ZERO );
MenuItemFont::setFontName("fonts/arial.ttf");
MenuItemFont::setFontSize(24);
MenuItemFont* autoTestItem = NULL;
if (LabelMainScene::_s_autoTest)
{
autoTestItem = MenuItemFont::create("Auto Test On",CC_CALLBACK_1(LabelMainScene::onAutoTest, this));
}
else
{
autoTestItem = MenuItemFont::create("Auto Test Off",CC_CALLBACK_1(LabelMainScene::onAutoTest, this));
}
autoTestItem->setTag(1);
autoTestItem->setPosition(Vec2( s.width - 90, s.height / 2));
autoTestItem->setColor(Color3B::RED);
menuAutoTest->addChild(autoTestItem);
addChild( menuAutoTest, 3, kTagAutoTestMenu );
_title = Label::createWithTTF(title().c_str(), "fonts/arial.ttf", 32);
addChild(_title, 1);
_title->setPosition(Vec2(s.width/2, s.height-50));
while(_quantityNodes < nodes)
onIncrease(this);
}
示例9: 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);
}
示例10: 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));
}