本文整理汇总了C++中CCMenuItemLabel::setTag方法的典型用法代码示例。如果您正苦于以下问题:C++ CCMenuItemLabel::setTag方法的具体用法?C++ CCMenuItemLabel::setTag怎么用?C++ CCMenuItemLabel::setTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCMenuItemLabel
的用法示例。
在下文中一共展示了CCMenuItemLabel::setTag方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
bool RPGDialogLayer::init(string titleStr, string menuOKStr, int menuItemOKTag, string menuCancelStr, int menuItemCancelTag, float width, float height, CCObject* target, SEL_MenuHandler seletor)
{
if(CCLayerColor::initWithColor(ccc4(0, 0, 0, 200), width, height))
{
this->initCommons(titleStr);
CCTMXTiledMap *mainBg = (CCTMXTiledMap*)this->getChildByTag(kRPGDialogLayerBg);
CCMenu *menu = (CCMenu*)mainBg->getChildByTag(kRPGDialogLayerBgMenu);
CCLabelTTF *menuOKLab = CCLabelTTF::create(OzgCCUtility::generalString(CCString::create(menuOKStr)->getCString()).c_str(), "Arial", 20, CCSizeMake(120, 25), kCCTextAlignmentCenter, kCCVerticalTextAlignmentCenter);
menuOKLab->setColor(ccc3(160, 160, 160));
CCMenuItemLabel *menuOK = CCMenuItemLabel::create(menuOKLab, target, seletor);
menuOK->setTag(menuItemOKTag);
menuOK->setPosition(ccp(100, 60));
menu->addChild(menuOK);
CCLabelTTF *menuCancelLab = CCLabelTTF::create(OzgCCUtility::generalString(CCString::create(menuCancelStr)->getCString()).c_str(), "Arial", 20, CCSizeMake(120, 25), kCCTextAlignmentCenter, kCCVerticalTextAlignmentCenter);
menuCancelLab->setColor(ccc3(160, 160, 160));
CCMenuItemLabel *menuCancel = CCMenuItemLabel::create(menuCancelLab, target, seletor);
menuCancel->setTag(menuItemCancelTag);
menuCancel->setPosition(ccp(280, 60));
menu->addChild(menuCancel);
return true;
}
return false;
}
示例2: showMainMenu
void RPGStartSceneLayer::showMainMenu()
{
CCMenu *mainMenu = CCMenu::create();
mainMenu->setAnchorPoint(CCPointZero);
mainMenu->setPosition(CCPointZero);
mainMenu->setTag(kRPGStartSceneLayerTagMainMenu);
this->addChild(mainMenu);
CCString *menuStartStr = (CCString*)this->m_stringList->objectForKey("mainmenu_start");
CCLabelTTF *menuStartLabel = CCLabelTTF::create(OzgCCUtility::generalString(menuStartStr->getCString()).c_str(), "FZCuYuan-M03S", 28, CCSizeMake(120, 40), kCCTextAlignmentCenter, kCCVerticalTextAlignmentCenter);
CCString *menuRestartStr = (CCString*)this->m_stringList->objectForKey("mainmenu_restart");
CCLabelTTF *menuRestartLabel = CCLabelTTF::create(OzgCCUtility::generalString(menuRestartStr->getCString()).c_str(), "FZCuYuan-M03S", 28, CCSizeMake(120, 40), kCCTextAlignmentCenter, kCCVerticalTextAlignmentCenter);
CCString *menuSettingsStr = (CCString*)this->m_stringList->objectForKey("mainmenu_settings");
CCLabelTTF *menuSettingsLabel = CCLabelTTF::create(OzgCCUtility::generalString(menuSettingsStr->getCString()).c_str(), "FZCuYuan-M03S", 28, CCSizeMake(120, 40), kCCTextAlignmentCenter, kCCVerticalTextAlignmentCenter);
CCMenuItemLabel *menuStart = CCMenuItemLabel::create(menuStartLabel, this, menu_selector(RPGStartSceneLayer::onMenu));
menuStart->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width / 2, 230));
menuStart->setTag(kRPGStartSceneLayerTagMainMenuItemStart);
mainMenu->addChild(menuStart);
CCMenuItemLabel *menuRestart = CCMenuItemLabel::create(menuRestartLabel, this, menu_selector(RPGStartSceneLayer::onMenu));
menuRestart->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width / 2, 170));
menuRestart->setTag(kRPGStartSceneLayerTagMainMenuItemRestart);
mainMenu->addChild(menuRestart);
CCMenuItemLabel *menuSettings = CCMenuItemLabel::create(menuSettingsLabel, this, menu_selector(RPGStartSceneLayer::onMenu));
menuSettings->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width / 2, 110));
menuSettings->setTag(kRPGStartSceneLayerTagMainMenuItemSettings);
mainMenu->addChild(menuSettings);
}
示例3: onNodeLoaded
void ChatLayer::onNodeLoaded(CCNode * pNode, CCNodeLoader * pNodeLoader)
{
m_txtAccount = CCEditBox::create(CCSizeMake(134, 30), CCScale9Sprite::create("transparent.png"));
this->addChild(m_txtAccount);
m_txtAccount->setPosition(ccp(215, 24));
m_txtAccount->setFontColor(ccc3(255,255,255));
m_txtAccount->setFont("Arial", 16);
CCMenu *menu = CCMenu::create();
this->addChild(menu);
menu->setPosition(ccp(33, 119));
// CCLabelBMFont* lblName = CCLabelBMFont::create("阵营", "test.fnt");
CCLabelTTF *lblShout = CCLabelTTF::create("喊话", FONT_VERDANA, FONT_SIZE_MEDIUM);
lblShout->setColor(ccc3(197, 255, 255));
lblShout->enableStroke(ccc3(69, 20, 21), 1);
CCMenuItemLabel* menuShout = CCMenuItemLabel::create(lblShout, this, menu_selector(ChatLayer::menuCallback));
menuShout->setPosition(ccp(4,80));
menuShout->setTag(101);
menu->addChild(menuShout);
CCLabelTTF *lblWorld = CCLabelTTF::create("世界", FONT_VERDANA, FONT_SIZE_MEDIUM);
lblWorld->setColor(ccc3(197, 255, 255));
lblWorld->enableStroke(ccc3(69, 20, 21), 1);
CCMenuItemLabel* menuWorld = CCMenuItemLabel::create(lblWorld, this, menu_selector(ChatLayer::menuCallback));
menuWorld->setPosition(ccp(4,50));
menuWorld->setTag(102);
menu->addChild(menuWorld);
CCLabelTTF *lblFaction = CCLabelTTF::create("阵营", FONT_VERDANA, FONT_SIZE_MEDIUM);
lblFaction->setColor(ccc3(197, 255, 255));
lblFaction->enableStroke(ccc3(69, 20, 21), 1);
CCMenuItemLabel* menuFaction = CCMenuItemLabel::create(lblFaction, this, menu_selector(ChatLayer::menuCallback));
menuFaction->setPosition(ccp(4,20));
menuFaction->setTag(103);
menu->addChild(menuFaction);
CCLabelTTF *lblGroup = CCLabelTTF::create("公会", FONT_VERDANA, FONT_SIZE_MEDIUM);
lblGroup->setColor(ccc3(197, 255, 255));
lblGroup->enableStroke(ccc3(69, 20, 21), 1);
CCMenuItemLabel* menuGroup = CCMenuItemLabel::create(lblGroup, this, menu_selector(ChatLayer::menuCallback));
menuGroup->setPosition(ccp(4,-10));
menuGroup->setTag(104);
menu->addChild(menuGroup);
CCLabelTTF *lblPrivate = CCLabelTTF::create("蜜语", FONT_VERDANA, FONT_SIZE_MEDIUM);
lblPrivate->setColor(ccc3(197, 255, 255));
lblPrivate->enableStroke(ccc3(69, 20, 21), 1);
CCMenuItemLabel* menuPrivate = CCMenuItemLabel::create(lblPrivate, this, menu_selector(ChatLayer::menuCallback));
menuPrivate->setPosition(ccp(4,-40));
menuPrivate->setTag(105);
menu->addChild(menuPrivate);
}
示例4: init
// on "init" you need to initialize your instance
bool StartLayer::init()
{
bool bRet = false;
do
{
CC_BREAK_IF(! CCLayer::init());
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
CCLabelTTF *label = CCLabelTTF::create("New Game", "Arial", 24 * 2);
CCMenuItemLabel *pMenuItem = CCMenuItemLabel::create(label, this, menu_selector(StartLayer::menuNewGameCallback));
pMenuItem->setTag(1);
pMenuItem->setPosition(winSize.width / 2, winSize.height / 2);
CCMenu* pMenu = CCMenu::create(pMenuItem, NULL);
pMenu->setPosition(CCPointZero);
CC_BREAK_IF(! pMenu);
this->addChild(pMenu, 1);
CCLabelTTF* pLabel = CCLabelTTF::create("Bubble Cat 2014", "Arial", 24 * 3);
CC_BREAK_IF(! pLabel);
pLabel->setPosition(ccp(winSize.width / 2, winSize.height - 50));
this->addChild(pLabel, 1);
CCSprite* pSprite = CCSprite::create("StartScene_CN.jpg");
CC_BREAK_IF(! pSprite);
pSprite->setPosition(ccp(winSize.width/2, winSize.height/2));
this->addChild(pSprite, 0);
bRet = true;
} while (0);
return bRet;
}
示例5: createMenuItem
void RPGBattleMenu::createMenuItem(float x, float y, CCString *text, RPGBattleMenuTag tag)
{
CCMenuItemLabel *menuItems = (CCMenuItemLabel*)this->getChildByTag(tag);
if(!menuItems)
{
CCLabelTTF *menuItemsLabel = CCLabelTTF::create(OzgCCUtility::generalString(text->getCString()).c_str(), "Arial", 28, CCSizeMake(120, 30), kCCTextAlignmentCenter, kCCVerticalTextAlignmentCenter);
CCMenuItemLabel *menuItems = CCMenuItemLabel::create(menuItemsLabel, this, menu_selector(RPGBattleMenu::onMenu));
menuItems->setPosition(ccp(x, y));
menuItems->setTag(tag);
this->addChild(menuItems);
}
}
示例6: init
bool LogoLayer::init()
{
if ( !CCLayer::init() )
{
return false;
}
// ask director the window size
CCSize size = CCDirector::sharedDirector()->getWinSize();
CCLabelTTF* beginLable = CCLabelTTF::create("Touch to begin", "Arial", 32);
beginLable->setOpacity((GLubyte)(120));
// CCRGBAProtocol *pRGBAProtocol = dynamic_cast<CCRGBAProtocol*>(beginLable);
// if (pRGBAProtocol)
// {
// pRGBAProtocol->setOpacity((GLubyte)(120));
// }
CCMenuItemLabel* pPlayItem = CCMenuItemLabel::create(beginLable, this, menu_selector(LogoLayer::menuCallback));
pPlayItem->setTag(1);
pPlayItem->setPosition(ccp( VisibleRect::center().x , VisibleRect::bottom().y+50 ));
beginLable->runAction(CCRepeatForever::create((CCActionInterval*)CCBlink::create(2, 2)));
CCLabelTTF* label = CCLabelTTF::create("COCOSBOX2D DEMO", "Arial", 64);
label->setAnchorPoint(ccp(1.0, 0.5));
addChild(label, 100, 1000);
label->setPosition( ccp(0, size.height-350) );
CCLabelTTF *sub = CCLabelTTF::create("cske", "Arial", 46);
sub->setAnchorPoint(ccp(1.0, 0.5));
addChild(sub, 100);
sub->setPosition(ccp(0, size.height-500));
CCActionInterval * move = CCSequence::create(CCDelayTime::create(1), CCMoveBy::create(4, ccp(650,0)), NULL);
label->runAction(move);
CCActionInterval * submove = CCSequence::create(CCDelayTime::create(5), CCMoveBy::create(4, ccp(400,0)), NULL);
sub->runAction(submove);
CCMenu* pMenu = CCMenu::create(pPlayItem, NULL);
pMenu->setPosition( CCPointZero );
addChild(pMenu, 1);
// CCSprite* pSprite = CCSprite::create("Default.png");
// pSprite->setPosition( ccp(size.width/2, size.height/2) );
// addChild(pSprite, 0);
b2Vec2 gravity;
gravity.Set(0.0f, 0.0f);
m_pWorld = new b2World(gravity);
m_pWorld->SetAllowSleeping(false);
m_pWorld->SetContinuousPhysics(true);
b2BodyDef groundBodyDef;
groundBodyDef.position.Set(0,0);
m_pGroundBody = m_pWorld->CreateBody(&groundBodyDef);
b2EdgeShape groundBox;
b2FixtureDef groundBoxDef;
groundBoxDef.shape =&groundBox;
groundBoxDef.friction = 0.0f;
groundBoxDef.restitution = 1.0;
groundBox.Set(b2Vec2(VisibleRect::leftBottom().x/PTM_RATIO,VisibleRect::leftBottom().y/PTM_RATIO), b2Vec2(VisibleRect::rightBottom().x/PTM_RATIO,VisibleRect::rightBottom().y/PTM_RATIO));
m_pGroundBody->CreateFixture(&groundBoxDef);
groundBox.Set(b2Vec2(VisibleRect::leftTop().x/PTM_RATIO,VisibleRect::leftTop().y/PTM_RATIO), b2Vec2(VisibleRect::leftBottom().x/PTM_RATIO,VisibleRect::leftBottom().y/PTM_RATIO));
m_pGroundBody->CreateFixture(&groundBoxDef);
groundBox.Set(b2Vec2(VisibleRect::leftTop().x/PTM_RATIO,VisibleRect::leftTop().y/PTM_RATIO), b2Vec2(VisibleRect::rightTop().x/PTM_RATIO,VisibleRect::rightTop().y/PTM_RATIO));
m_pGroundBody->CreateFixture(&groundBoxDef);
groundBox.Set(b2Vec2(VisibleRect::rightBottom().x/PTM_RATIO,VisibleRect::rightBottom().y/PTM_RATIO), b2Vec2(VisibleRect::rightTop().x/PTM_RATIO,VisibleRect::rightTop().y/PTM_RATIO));
m_pGroundBody->CreateFixture(&groundBoxDef);
CCPoint firePosition(100, 200);
b2BodyDef fireBodyDef;
fireBodyDef.position.Set(firePosition.x / PTM_RATIO, firePosition.y / PTM_RATIO);
fireBodyDef.type = b2_dynamicBody;
m_pFireBody = m_pWorld->CreateBody(&fireBodyDef);
b2CircleShape fireShape;
fireShape.m_radius = 10 / PTM_RATIO / 2;
b2FixtureDef fireShapeDef;
fireShapeDef.shape = &fireShape;
fireShapeDef.density = 1.0f;
fireShapeDef.friction = 0.1f;
fireShapeDef.restitution = 1.0f;
m_pFireBody->CreateFixture(&fireShapeDef);
b2Vec2 force = b2Vec2(50, -50);
m_pFireBody->ApplyLinearImpulse(force, m_pFireBody->GetWorldCenter());
m_pFireEmitter = CCParticleSun::createWithTotalParticles(500);
m_pFireEmitter->setPosition(firePosition);
m_pFireEmitter->setTexture( CCTextureCache::sharedTextureCache()->addImage("fire.png"));
addChild(m_pFireEmitter, 5);
CCPoint icePosition(200, 600);
fireBodyDef.position.Set(icePosition.x / PTM_RATIO, icePosition.y / PTM_RATIO);
m_pIceBody = m_pWorld->CreateBody(&fireBodyDef);
m_pIceBody->CreateFixture(&fireShapeDef);
m_pIceBody->ApplyLinearImpulse(force, m_pFireBody->GetWorldCenter());
//.........这里部分代码省略.........
示例7: showSettingsMenu
void RPGStartSceneLayer::showSettingsMenu()
{
RPGSaveData *saveDataObj = loadSaveData(&this->m_db);
CCMenu *settingsMenu = CCMenu::create();
settingsMenu->setAnchorPoint(CCPointZero);
settingsMenu->setPosition(CCPointZero);
settingsMenu->setTag(kRPGStartSceneLayerTagSettingsMenu);
this->addChild(settingsMenu);
//设置样式的标题
CCString *labStyleStr = (CCString*)this->m_stringList->objectForKey("settingslab_style");
CCLabelTTF *labStyleLabel = CCLabelTTF::create(OzgCCUtility::generalString(labStyleStr->getCString()).c_str(), "FZCuYuan-M03S", 28, CCSizeMake(120, 40), kCCTextAlignmentLeft, kCCVerticalTextAlignmentCenter);
labStyleLabel->setFontFillColor(ccc3(188, 188, 188));
labStyleLabel->setTag(kRPGStartSceneLayerTagLabStyle);
labStyleLabel->setPosition(ccp(300, 550));
this->addChild(labStyleLabel);
//设置样式的按钮
CCLabelTTF *menuStyleLeftLabel = CCLabelTTF::create("<<", "FZCuYuan-M03S", 28, CCSizeMake(120, 40), kCCTextAlignmentCenter, kCCVerticalTextAlignmentCenter);
CCMenuItemLabel *menuStyleLeft = CCMenuItemLabel::create(menuStyleLeftLabel, this, menu_selector(RPGStartSceneLayer::onMenu));
menuStyleLeft->setPosition(ccp(450, 550));
menuStyleLeft->setTag(kRPGStartSceneLayerTagSettingsStyleLeft);
settingsMenu->addChild(menuStyleLeft);
CCLabelTTF *menuStyleRightLabel = CCLabelTTF::create(">>", "FZCuYuan-M03S", 28, CCSizeMake(120, 40), kCCTextAlignmentCenter, kCCVerticalTextAlignmentCenter);
CCMenuItemLabel *menuStyleRight = CCMenuItemLabel::create(menuStyleRightLabel, this, menu_selector(RPGStartSceneLayer::onMenu));
menuStyleRight->setPosition(ccp(650, 550));
menuStyleRight->setTag(kRPGStartSceneLayerTagSettingsStyleRight);
settingsMenu->addChild(menuStyleRight);
//设置样式的当前使用样式
CCString *labCurrStyleStr = NULL;
for (int i = 0; i < this->m_styleData.size(); i++)
{
pair<string, string> item = this->m_styleData[i];
if(strcmp(item.first.c_str(), saveDataObj->m_windowStyle.c_str()) == 0)
{
this->m_selectedStyleIndex = i;
labCurrStyleStr = CCString::create(item.second);
break;
}
}
if(labCurrStyleStr)
{
CCLabelTTF *labCurrStyleLabel = CCLabelTTF::create(OzgCCUtility::generalString(labCurrStyleStr->getCString()).c_str(), "FZCuYuan-M03S", 28, CCSizeMake(120, 40), kCCTextAlignmentCenter, kCCVerticalTextAlignmentCenter);
labCurrStyleLabel->setFontFillColor(ccc3(188, 188, 188));
labCurrStyleLabel->setTag(kRPGStartSceneLayerTagLabCurrStyle);
labCurrStyleLabel->setPosition(ccp(550, 550));
this->addChild(labCurrStyleLabel);
}
//恢复默认
CCString *menuRestoreStr = (CCString*)this->m_stringList->objectForKey("settingsmenu_restore");
CCLabelTTF *menuRestoreLabel = CCLabelTTF::create(OzgCCUtility::generalString(menuRestoreStr->getCString()).c_str(), "FZCuYuan-M03S", 28, CCSizeMake(120, 40), kCCTextAlignmentLeft, kCCVerticalTextAlignmentCenter);
CCMenuItemLabel *menuRestore = CCMenuItemLabel::create(menuRestoreLabel, this, menu_selector(RPGStartSceneLayer::onMenu));
menuRestore->setPosition(ccp(300, 170));
menuRestore->setTag(kRPGStartSceneLayerTagSettingsRestore);
settingsMenu->addChild(menuRestore);
//返回
CCString *menuBackStr = (CCString*)this->m_stringList->objectForKey("settingsmenu_back");
CCLabelTTF *menuBackLabel = CCLabelTTF::create(OzgCCUtility::generalString(menuBackStr->getCString()).c_str(), "FZCuYuan-M03S", 28, CCSizeMake(120, 40), kCCTextAlignmentLeft, kCCVerticalTextAlignmentCenter);
CCMenuItemLabel *menuBack = CCMenuItemLabel::create(menuBackLabel, this, menu_selector(RPGStartSceneLayer::onMenu));
menuBack->setPosition(ccp(300, 100));
menuBack->setTag(kRPGStartSceneLayerTagSettingsBack);
settingsMenu->addChild(menuBack);
}
示例8: avgGame
void StoryWorld::avgGame(void) {
CCLabelTTF* myDialog = (CCLabelTTF *)getChildByTag(100);
CCLabelTTF* myName = (CCLabelTTF *)getChildByTag(101);
CCSpriteBatchNode *spriteBatch = (CCSpriteBatchNode *)getChildByTag(102);
CCSprite *myLeftSprite = (CCSprite *)spriteBatch->getChildByTag(1);
CCSprite *myRightSprite = (CCSprite *)spriteBatch->getChildByTag(2);
strcpy(dialog, reader.GetNextDialog().c_str());
char theName[10][11]={"","穆婧:", "子轩:", "少杰:", "建国", "路人A:", "路人B:", "路人C:", "老爷爷:", "江姐:"};
myName->setString(theName[dialog[0]-48]);
characterPasterSwitchCase(dialog[0]);
switch (dialog[2]) {
case '1': {
setTouchEnabled(false);
CCSprite *back = CCSprite::create(LANDSCAPE_IMG_PATH);
back->setPosition(ccp(CCDirector::sharedDirector()->getVisibleSize().width/2, CCDirector::sharedDirector()->getVisibleSize().height/2));
back->setOpacity(150);
back->setTag(3);
addChild(back, 3);
switch (current) {
case '3': {
CCLabelTTF *Label1 = CCLabelTTF::create("Yes", "Heiti SC", 40);
CCLabelTTF *Label2 = CCLabelTTF::create("No", "Heiti SC", 40);
CCMenuItemLabel *firstChoice = CCMenuItemLabel::create(Label1, this, menu_selector(StoryWorld::leafletChoiceHandler));
CCMenuItemLabel *secondChoice = CCMenuItemLabel::create(Label2, this, menu_selector(StoryWorld::leafletChoiceHandler));
firstChoice->setTag(fChoice);
secondChoice->setTag(sChoice);
firstChoice->setPosition(ccp(CCDirector::sharedDirector()->getVisibleSize().width/2, CCDirector::sharedDirector()->getVisibleSize().height/5 * 4.1));
secondChoice->setPosition(ccp(CCDirector::sharedDirector()->getVisibleSize().width/2, CCDirector::sharedDirector()->getVisibleSize().height/5 * 2.9));
CCMenu *menu = CCMenu::create(firstChoice, secondChoice, NULL);
menu->setPosition(CCPointZero);
menu->setTag(2);
addChild(menu, 3);
return;
}
break;
case '9': {
CCLabelTTF *Label1 = CCLabelTTF::create("子轩", "Heiti SC", 40);
CCLabelTTF *Label2 = CCLabelTTF::create("少杰", "Heiti SC", 40);
CCLabelTTF *Label3 = CCLabelTTF::create("建国", "Heiti SC", 40);
CCMenuItemLabel *firstChoice = CCMenuItemLabel::create(Label1, this, menu_selector(StoryWorld::theFinalChoiceHandler));
CCMenuItemLabel *secondChoice = CCMenuItemLabel::create(Label2, this, menu_selector(StoryWorld::theFinalChoiceHandler));
CCMenuItemLabel *thirdChoice = CCMenuItemLabel::create(Label3, this, menu_selector(StoryWorld::theFinalChoiceHandler));
firstChoice->setTag(fChoice);
secondChoice->setTag(sChoice);
thirdChoice->setTag(tChoice);
firstChoice->setPosition(ccp(CCDirector::sharedDirector()->getVisibleSize().width/2, CCDirector::sharedDirector()->getVisibleSize().height/5 * 4.1));
secondChoice->setPosition(ccp(CCDirector::sharedDirector()->getVisibleSize().width/2, CCDirector::sharedDirector()->getVisibleSize().height/5 * 2.9));
thirdChoice->setPosition(ccp(CCDirector::sharedDirector()->getVisibleSize().width/2, CCDirector::sharedDirector()->getVisibleSize().height/5 * 1.8));
CCMenu *menu = CCMenu::create(firstChoice, secondChoice, thirdChoice, NULL);
menu->setPosition(CCPointZero);
menu->setTag(2);
addChild(menu, 3);
return;
}
break;
default:
break;
}
}
break;
case '2': {
}
break;
case '3': {
if (myLeftSprite->getOpacity() == 0)
myLeftSprite->setOpacity(255);
else
myLeftSprite->runAction(CCFadeOut::create(1));
}
break;
case '4': {
if (myRightSprite->getOpacity() == 0)
myRightSprite->setOpacity(255);
else
myRightSprite->runAction(CCFadeOut::create(1));
}
break;
case '5': {
if (myRightSprite->getOpacity()==0 && myLeftSprite->getOpacity()==0) {
myLeftSprite->setOpacity(255);
myRightSprite->setOpacity(255);
} else if (myRightSprite->getOpacity()!=0 && myLeftSprite->getOpacity()!=0) {
myLeftSprite->runAction(CCFadeOut::create(1));
myRightSprite->runAction(CCFadeOut::create(1));
}
}
break;
default:
break;
}
specialPartSwitchCase(dialog[3]);
//.........这里部分代码省略.........
示例9: avgGame
void StoryWorld::avgGame(void) {
CCLabelTTF* myDialog = (CCLabelTTF *)getChildByTag(100);
CCLabelTTF* myName = (CCLabelTTF *)getChildByTag(101);
CCSpriteBatchNode *spriteBatch = (CCSpriteBatchNode *)getChildByTag(102);
CCSprite *myLeftSprite = (CCSprite *)spriteBatch->getChildByTag(1);
CCSprite *myRightSprite = (CCSprite *)spriteBatch->getChildByTag(2);
strcpy(dialog, reader.GetNextDialog().c_str());
char theName[10][11]={"","穆婧1:", "子轩:", "少杰:", "建国", "路人A:", "路人B:", "路人C:", "老爷爷:", "江姐:"};
myName->setString(theName[dialog[0]-48]);
//任务立绘切换
switch (dialog[0]) {
case '0': { //无人
char b[10]="me_ .png";
b[3] = dialog[1]+1;
myLeftSprite->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(b));
}
break;
case '1': { //ME
char b[10]="me_ .png";
b[3] = dialog[1]+1;
myLeftSprite->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(b));
}
break;
case '2': { //子轩
char b[10]="zx_ .png";
b[3] = dialog[1]+1;
myRightSprite->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(b));
}
break;
case '3': { //少杰
char b[10]="sj_ .png";
b[3] = dialog[1];
myRightSprite->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(b));
}
break;
case '4': { //建国
char b[10]="jg_ .png";
b[3] = dialog[1];
myRightSprite->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(b));
}
break;
case '5': {
char b[10]="la_ .png";
b[3] = dialog[1];
myRightSprite->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(b));
}
break;
case '6': {
char b[10]="lb_ .png";
b[3] = dialog[1];
myRightSprite->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(b));
}
break;
case '7': {
char b[10]="lc_ .png";
b[3] = dialog[1];
myRightSprite->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(b));
}
break;
case '8': {
char b[10]="yy_ .png";
b[3] = dialog[1];
myRightSprite->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(b));
}
break;
case '9': {
char b[10]="jj_ .png";
b[3] = dialog[1];
myRightSprite->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(b));
}
break;
default:
break;
}
switch (dialog[2]) {
// 选择走向
case '1': {
//开始选择走向
//停止触摸
setTouchEnabled(false);
CCSprite *back = CCSprite::create(LANDSCAPE_IMG_PATH);
back->setPosition(ccp(CCDirector::sharedDirector()->getVisibleSize().width/2, CCDirector::sharedDirector()->getVisibleSize().height/2));
back->setOpacity(150);
back->setTag(3);
addChild(back, 3);
switch (current) {
case '3': {
CCLabelTTF *Label1 = CCLabelTTF::create("Yes", "Heiti SC", 40);
CCLabelTTF *Label2 = CCLabelTTF::create("No", "Heiti SC", 40);
CCMenuItemLabel *firstChoice = CCMenuItemLabel::create(Label1, this, menu_selector(StoryWorld::makeAChoice));
CCMenuItemLabel *secondChoice = CCMenuItemLabel::create(Label2, this, menu_selector(StoryWorld::makeAChoice));
firstChoice->setTag(fChoice);
secondChoice->setTag(sChoice);
firstChoice->setPosition(ccp(CCDirector::sharedDirector()->getVisibleSize().width/2, CCDirector::sharedDirector()->getVisibleSize().height/5 * 4.1));
secondChoice->setPosition(ccp(CCDirector::sharedDirector()->getVisibleSize().width/2, CCDirector::sharedDirector()->getVisibleSize().height/5 * 2.9));
CCMenu *menu = CCMenu::create(firstChoice, secondChoice, NULL);
//.........这里部分代码省略.........