本文整理汇总了C++中CCLayer::setTag方法的典型用法代码示例。如果您正苦于以下问题:C++ CCLayer::setTag方法的具体用法?C++ CCLayer::setTag怎么用?C++ CCLayer::setTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCLayer
的用法示例。
在下文中一共展示了CCLayer::setTag方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void Newbie1Trigger::toNextCallBack(cocos2d::CCNode *pSender) {
if (statues == 0) {
node->removeChildByTag(newbieFlowLayerTag,true);
CCLayer* newbieLayer = CCLayer::create();
CCSprite* gray = CCSprite::create("whiteImage.jpg");
gray->setPosition(ccp(winSize.width/2,winSize.height/2));
gray->setScaleX(winSize.width/gray->getContentSize().width);
gray->setScaleY(winSize.height/gray->getContentSize().height);
gray->setColor(ccc3(0,0,0));
gray->setOpacity(0);
gray->runAction(CCFadeTo::create(0.5,150));
newbieLayer->addChild(gray);
CCString* str = GXUtil::readFile("NewbieDialog1.j");
node->addChild(DiaLayer::create(GXJsonUtil::parseDiaLayerInfoBean(str->getCString())),11);
newbieLayer->setTag(newbieFlowLayerTag);
node->addChild(newbieLayer);
MyMenuItem* sprite = MyMenuItem::create(CCSprite::create("skipTutorials.png"),this,menu_selector(Newbie1Trigger::toSkip));
sprite->setPosition(ccp(winSize.width-200,550));
MyPriorityMenu* skipMenu = MyPriorityMenu::create(-601,sprite,NULL);
skipMenu->setPosition(ccp(0,0));
skipMenu->setTag(skipMenuLayerTag);
node->addChild(skipMenu);
statues++;
} else if(statues == 1) {
Newbie1to2Message::create()->sendMsg();
}
// CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("sfx_click.mp3");
}
示例2: scene
cocos2d::CCScene* BYGameScene::scene() {
CCScene *scene = CCScene::create();
// add layer as a child to scene
CCLayer* layer = new BYGameScene();
layer->setTag(GUI_MainLayer);
scene->addChild(layer);
layer->autorelease();
return scene;
}
示例3: toServerList
void ThirdServerScene::toServerList() {
if (this->getChildByTag(loginLayerTag) != NULL) {
this->removeChildByTag(loginLayerTag,true);
}
CCLayer* loginLayer = CCLayer::create();
loginLayer->setTag(loginLayerTag);
loginLayer->setPosition(ccp(0,0));
CCLayer* displayLayer = CCLayer::create();
CCSprite* loginBack = CCSprite::createWithSpriteFrameName("serverShadow.png");
loginBack->setPosition(ccp(0,0));
loginBack->setAnchorPoint(ccp(1,0));
loginBack->setScale(2);
displayLayer->addChild(loginBack);
displayLayer->setTag(loginDisplayLayerTag);
loginLayer->addChild(displayLayer);
displayLayer->setPosition(ccp(winSize.width-645,960));
CCSprite* serverListLabel = CCSprite::createWithSpriteFrameName("serverlistTipLabel.png");
serverListLabel->setPosition(ccp(-285,325));
displayLayer->addChild(serverListLabel);
// CCSprite* upTip = CCSprite::createWithSpriteFrameName("serverlistTipCornor.png");
// upTip->setPosition(ccp(-300,65));
// upTip->setRotation(180);
// upTip->setScale(0.66);
// upTip->setColor(ccc3(200,200,200));
// upTip->setTag(upTipTag);
//
// displayLayer->addChild(upTip);
CCSprite* downTip = CCSprite::createWithSpriteFrameName("serverlistTipCornor.png");
downTip->setPosition(ccp(-300,50));
downTip->setScale(0.66);
downTip->setColor(ccc3(200,200,200));
downTip->setTag(downTipTag);
downTip->runAction(CCRepeatForever::create(static_cast<CCSequence*>(CCSequence::create( CCEaseIn::create(CCMoveBy::create(0.25,ccp(0,-10)),1.5),CCEaseOut::create(CCMoveBy::create(0.25,ccp(0,10)),1.5),NULL))));
displayLayer->addChild(downTip);
displayLayer->runAction(CCEaseElasticOut::create(CCMoveTo::create(0.35, ccp(winSize.width-394,280)), 1));
CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("sfx_popCreator.mp3");
CCObject* obj;
int i = 0;
ServerSelectScroll2* scroll = ServerSelectScroll2::create(-507);
scroll->setOriPosition(ccp(winSize.width-890,370));
scroll->setContentSize(CCSizeMake(450, 200));
scroll->setMapSize(CCSizeMake(450, 50*(beans->count()+3)));
scroll->setPosition(ccp(winSize.width-765+0.33*50*(beans->count()-1)-224,-scroll->getMapSize().height+scroll->getViewSize().height+scroll->getOriPosition().y+680));
scroll->runAction(CCEaseElasticOut::create(CCMoveBy::create(0.35, ccp(224,-680)), 1));
CCARRAY_FOREACH(beans,obj) {
SeverInfoBean* bean = (SeverInfoBean*)obj;
CCSprite* layer = CCSprite::create("transparent.png");
// CCSprite* transParent = CCSprite::create("transparent.png");
layer->setScaleX(270/layer->getContentSize().width);
layer->setScaleY(33/layer->getContentSize().height);
layer->setContentSize(CCSizeMake(225,33));
layer->setOpacity(100);
CCLabelTTF* label = CCLabelTTF::create(bean->getServerName()->getCString(),"Arial",33);
label->setPosition(ccp(90/layer->getScaleX(),16/layer->getScaleY()));
layer->addChild(label,2);
label->setTag(serverNameLabelTag);
label->setScaleX(1/layer->getScaleX());
label->setScaleY(1/layer->getScaleY());
if (bean->serverId == cacheServerId) {
label->setColor(ccc3(155,155,155));
}
CCLabelTTF* stateLabel =CCLabelTTF::create(bean->getServerStatus()->getCString(),"Arial",30);
stateLabel->setPosition(ccp(236/layer->getScaleX(),16/layer->getScaleY()));
if (bean->getServerStatus()->compare("正常") == 0 || bean->getServerStatus()->compare("推荐") == 0) {
stateLabel->setColor(ccc3(0,255,0));
} else if (bean->getServerStatus()->compare("繁忙") == 0) {
stateLabel->setColor(ccc3(255,255,0));
} else if (bean->getServerStatus()->compare("火爆") == 0) {
stateLabel->setColor(ccc3(167,87,168));
} else {
stateLabel->setColor(ccc3(166,166,166));
}
stateLabel->setScaleX(1/layer->getScaleX());
stateLabel->setScaleY(1/layer->getScaleY());
layer->addChild(stateLabel,2);
MyMenuItem* serverItem = MyMenuItem::create(layer,this,menu_selector(ThirdServerScene::toChangeServer));
serverItem->setPosition(ccp(-(i+3)*17+135,26+50*(i+3)));
// serverItem->setAnchorPoint(ccp(0,0));
serverItem->setUserObject(bean);
scroll->addChild(serverItem);
// dividingLength*i+33
i++;
}
示例4: initServerInfo
void ThirdServerScene::initServerInfo(SeverInfoBean* bean) {
this->removeChildByTag(serverInfoLayerTag,true);
selectBean = bean;
CCLayer* serverInfoLayer = CCLayer::create();
serverInfoLayer->setTag(serverInfoLayerTag);
serverInfoLayer->setPosition(ccp(0,0));
this->cacheServerId = bean->serverId;
char str[30] = {0};
sprintf(str,"s%d_ititaId",bean->serverId);
std::string ititaId = CCUserDefault::sharedUserDefault()->getStringForKey(str,"");
bool ititaIdFlag = false;
if (ititaId.compare("") != 0 && ititaId.compare(PulsarNative::getDeviceId()) != 0) {
ititaIdFlag = true;
}
MyMenuItem* leftButton = MyMenuItem::create(CCSprite::createWithSpriteFrameName("serverButton.png"),NULL,NULL);
leftButton->setAnchorPoint(ccp(1,0.5));
// leftButton->setPosition(ccp(winSize.width+100,240));
leftButton->setPosition(ccp(winSize.width+422,240));
leftButton->runAction(CCSequence::create(CCDelayTime::create(0.1),CCEaseElasticOut::create(CCMoveTo::create(0.3,ccp(winSize.width+100,240)),1),NULL));
CCSprite* registLabel;
if (ititaIdFlag) {
registLabel = CCSprite::createWithSpriteFrameName("serverSwitchLabel.png");
leftButton->setTarget(this,menu_selector(ThirdServerScene::toLogin));
} else {
registLabel = CCSprite::createWithSpriteFrameName("serverBindLabel.png");
leftButton->setTarget(this,menu_selector(ThirdServerScene::toRegister));
}
registLabel->setAnchorPoint(ccp(0,0.5));
registLabel->setPosition(ccp(30,leftButton->getContentSize().height/2));
leftButton->addChild(registLabel);
MyMenuItem* rightButton = MyMenuItem::create(CCSprite::createWithSpriteFrameName("serverButton.png"),this,menu_selector(ThirdServerScene::fastEnterGameWait));
rightButton->setAnchorPoint(ccp(1,0.5));
// rightButton->setPosition(ccp(winSize.width+20,330));
rightButton->setPosition(ccp(winSize.width+342,330));
rightButton->runAction(CCSequence::create(CCEaseElasticOut::create(CCMoveTo::create(0.3,ccp(winSize.width+20,330)),1),NULL));
CCSprite* newLabel;
if (ititaIdFlag) {
newLabel = CCSprite::createWithSpriteFrameName("serverEnterGame.png");
} else {
newLabel = CCSprite::createWithSpriteFrameName("serverFastStartLabel.png");
}
newLabel->setAnchorPoint(ccp(0,0.5));
newLabel->setPosition(ccp(30,rightButton->getContentSize().height/2));
rightButton->addChild(newLabel);
MyPriorityMenu* menu = MyPriorityMenu::create(-501,leftButton,rightButton,NULL);
menu->setPosition(ccp(0,0));
serverInfoLayer->addChild(menu);
// sprintf(str,"s%d_nickname",bean->serverId);
// std::string nickname = CCUserDefault::sharedUserDefault()->getStringForKey(str,"");
//
// if (nickname.compare("") != 0) {
// CCLabelTTF* id = CCLabelTTF::create("ID:","Arial",40);
// id->setColor(ccc3(255,222,0));
//
// CCLabelTTF* nicknameLabel = CCLabelTTF::create(nickname.c_str(),"Arial",40);
// float locx = id->getContentSize().width+nicknameLabel->getContentSize().width;
// id->setAnchorPoint(ccp(0,0.5));
// id->setPosition(ccp(winSize.width-locx/2-180,400));
// nicknameLabel->setAnchorPoint(ccp(0,0.5));
// nicknameLabel->setPosition(ccp(winSize.width-locx/2+id->getContentSize().width-190,400));
// serverInfoLayer->addChild(id);
// serverInfoLayer->addChild(nicknameLabel);
// }
CCLayer* layer = CCLayer::create();
CCLabelTTF* label = CCLabelTTF::create(bean->getServerName()->getCString(),"Arial",33);
label->setPosition(ccp(224,2));
layer->addChild(label);
label->setTag(serverNameLabelTag);
CCLabelTTF* stateLabel =CCLabelTTF::create(bean->getServerStatus()->getCString(),"Arial",30);
stateLabel->setPosition(ccp(340,0));
if (bean->getServerStatus()->compare("正常") == 0 || bean->getServerStatus()->compare("推荐") == 0) {
stateLabel->setColor(ccc3(0,255,0));
} else if (bean->getServerStatus()->compare("繁忙") == 0) {
stateLabel->setColor(ccc3(255,255,0));
} else if (bean->getServerStatus()->compare("火爆") == 0) {
stateLabel->setColor(ccc3(167,87,168));
} else {
stateLabel->setColor(ccc3(166,166,166));
}
layer->addChild(stateLabel);
CCSprite* serverBack = CCSprite::createWithSpriteFrameName("serverCurentServerBack.png");
// serverBack->setPosition(ccp(winSize.width+35,48));
serverBack->setPosition(ccp(winSize.width+357,48));
serverBack->runAction(CCSequence::create(CCDelayTime::create(0.3),CCEaseElasticOut::create(CCMoveTo::create(0.3,ccp(winSize.width+35,48)),1),NULL));
//.........这里部分代码省略.........
示例5: ccp
bool Newbie1Trigger::onRegist() {
// CCLayer* newbieLayer = CCLayer::create();
//
// CCSprite* gray = CCSprite::create("whiteImage.jpg");
// gray->setPosition(ccp(winSize.width/2,winSize.height/2));
// gray->setScaleX(winSize.width/gray->getContentSize().width);
// gray->setScaleY(winSize.height/gray->getContentSize().height);
// gray->setColor(ccc3(0,0,0));
// gray->setOpacity(150);
//
// newbieLayer->addChild(gray);
//
// CCString* str = GXUtil::readFile("NewbieDialog1.j");
// node->addChild(DiaLayer::create(GXJsonUtil::parseDiaLayerInfoBean(str->getCString())),11);
// newbieLayer->setTag(newbieFlowLayerTag);
// node->addChild(newbieLayer);
CocosDenshion::SimpleAudioEngine::sharedEngine()->preloadEffect("sfx_uicrash.mp3");
CocosDenshion::SimpleAudioEngine::sharedEngine()->preloadEffect("sfx_uicrash1.mp3");
CCLayer* newbieLayer = CCLayer::create();
newbieLayer->setTag(newbieFlowLayerTag);
CCSprite* black = CCSprite::create("whiteImage.jpg");
black->setColor(ccc3(0,0,0));
black->setScaleX(winSize.width/black->getContentSize().width);
black->setScaleY(winSize.height/black->getContentSize().height);
newbieLayer->addChild(black);
// black->setTag(newbieBlackTag);
black->setPosition(ccp(winSize.width/2,winSize.height/2));
CCLabelTTF* label = CCLabelTTF::create("1939.10.30\n天气 晴\n欧洲战场前线基地", "Arial", 36,CCSizeZero, kCCTextAlignmentLeft, kCCVerticalTextAlignmentTop);
label->setPosition(ccp(200,150));
label->setOpacity(0);
label->runAction(CCSequence::create(CCFadeIn::create(0.5),CCDelayTime::create(1.5),CCFadeOut::create(3),GXRemoveFromParentsAction::create(),NULL));
black->runAction(CCSequence::create(CCDelayTime::create(2),CCFadeOut::create(3),NULL));
newbieLayer->addChild(label);
GXShieldTouchMenuItem* nextButton = GXShieldTouchMenuItem::create();
nextButton->setContentSize(winSize);
nextButton->setPosition(ccp(winSize.width/2,winSize.height/2));
MyPriorityMenu* menu = MyPriorityMenu::create(-499, nextButton,NULL);
menu->setPosition(ccp(0,0));
// menu->setTag(newbieMenuTag);
newbieLayer->addChild(menu);
node->addChild(newbieLayer);
// node->runAction(CCRepeat::create(static_cast<CCSequence*>(CCSequence::create(CCCallFunc::create(this,callfunc_selector(Newbie1Trigger::deployUnit)),CCDelayTime::create(1),NULL)),20));
MyBattleMap* battleMap = (MyBattleMap*)node->getChildByTag(MainMapTag);
battleMap->runAction(CCSequence::create(CCDelayTime::create(3),CCEaseIn::create(CCMoveBy::create(9,ccp(-500,-500)),2),CCCallFunc::create(this,callfunc_selector(Newbie1Trigger::toNextCallBack)),NULL));
CCArray* unitArray = CCArray::create();
CreatorInfoBean* PanzerIVBean = CreatorInfoBean::create(PanzerIVCardId);
CreatorInfoBean* VolksgrenadierBean = CreatorInfoBean::create(volksgrenaierCardId);
// CreatorInfoBean* InfanterieBean = CreatorInfoBean::create(InfanterieCardId);
CreatorInfoBean* PanzergrenadierBean = CreatorInfoBean::create(panzergrenadierCardId);
// CreatorInfoBean* HummingBirdBean = CreatorInfoBean::create(HummingBirdCardId);
// CreatorInfoBean* tigerBean = CreatorInfoBean::create(TigerCardId);
MyUnit* unit1 = PanzerIVBean->creator->createObj(PanzerIVBean->getLevel());
unit1->setTag(PanzerIVBean->creator->cardId);
unit1->setPosition(battleMap->transTiledToMap(ccp(25,50)));
unit1->deployPosi = ccp(25,50);
unitArray->addObject(unit1);
MyUnit* unit2 = PanzerIVBean->creator->createObj(PanzerIVBean->getLevel());
unit2->setTag(PanzerIVBean->creator->cardId);
unit2->setPosition(battleMap->transTiledToMap(ccp(30,55)));
unit2->deployPosi = ccp(30,55);
unitArray->addObject(unit2);
MyUnit* unit3 = VolksgrenadierBean->creator->createObj(1);
unit3->setTag(VolksgrenadierBean->creator->cardId);
unit3->setPosition(battleMap->transTiledToMap(ccp(24,54)));
unit3->deployPosi = ccp(24,54);
unitArray->addObject(unit3);
MyUnit* unit4 = VolksgrenadierBean->creator->createObj(1);
unit4->setTag(VolksgrenadierBean->creator->cardId);
unit4->setPosition(battleMap->transTiledToMap(ccp(35,50)));
unit4->deployPosi = ccp(35,50);
unitArray->addObject(unit4);
MyUnit* unit5 = VolksgrenadierBean->creator->createObj(1);
unit5->setTag(VolksgrenadierBean->creator->cardId);
unit5->setPosition(battleMap->transTiledToMap(ccp(33,59)));
unit5->deployPosi = ccp(33,59);
unitArray->addObject(unit5);
MyUnit* unit6 = PanzergrenadierBean->creator->createObj(1);
unit6->setTag(PanzergrenadierBean->creator->cardId);
unit6->setPosition(battleMap->transTiledToMap(ccp(23,52)));
unit6->deployPosi = ccp(23,52);
unitArray->addObject(unit6);
//.........这里部分代码省略.........