本文整理汇总了C++中CCLayerColor::setTag方法的典型用法代码示例。如果您正苦于以下问题:C++ CCLayerColor::setTag方法的具体用法?C++ CCLayerColor::setTag怎么用?C++ CCLayerColor::setTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCLayerColor
的用法示例。
在下文中一共展示了CCLayerColor::setTag方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void LevelGame05::pauseCallback(CCObject *pSender)
{
CCSize size = CCDirector::sharedDirector()->getWinSize();
CCLayerColor *layer = CCLayerColor::create(ccc4(0, 0, 0, 200), size.width, size.height);
layer->setTag(80);
CCMenu *pmenu=(CCMenu *)getChildByTag(100);//9¸ö²Ëµ¥Ïî½ûÖ¹
pmenu->setEnabled(false);
CCMenu *pause=(CCMenu *)getChildByTag(101);//101ÊÇÔÝÍ£ÔٴνûÖ¹
pause->setEnabled(false);
CCSprite *sp =CCSprite::createWithSpriteFrameName("bg.png");
sp->setPosition(CCPoint(size.width*0.5, size.height*0.5));
layer->addChild(sp);
CCSpriteFrameCache *cache = CCSpriteFrameCache::sharedSpriteFrameCache();
CCMenuItemImage *closeItem = CCMenuItemImage::create();
closeItem->setNormalSpriteFrame(cache->spriteFrameByName("back-1.png"));
closeItem->setSelectedSpriteFrame(cache->spriteFrameByName("back-2.png"));
closeItem->initWithTarget(this, menu_selector(LevelGame05::menuCloseCallback));
closeItem->setPosition(CCPoint(size.width*0.1,80));
CCMenu *menus = CCMenu::create(closeItem, NULL);
menus->setPosition(CCPointZero);
layer->addChild(menus);
CCMenuItemImage *Item1 = CCMenuItemImage::create();
Item1->setNormalSpriteFrame(cache->spriteFrameByName("home-1.png"));
Item1->setSelectedSpriteFrame(cache->spriteFrameByName("home-2.png"));
Item1->initWithTarget(this,menu_selector(LevelGame05::homeCallback));
Item1->setPosition(ccp(size.width*0.5-300, size.height*0.5));
Item1->setTag(125);
CCMenuItemImage *Item2 = CCMenuItemImage::create();
Item2->setNormalSpriteFrame(cache->spriteFrameByName("pause-list-1.png"));
Item2->setSelectedSpriteFrame(cache->spriteFrameByName("pause-list-2.png"));
Item2->initWithTarget(this,menu_selector(LevelGame05::winloseCallback));
Item2->setPosition(ccp(size.width*0.5, size.height*0.5));
Item2->setTag(126);
CCMenuItemImage *Item3 = CCMenuItemImage::create();
if(isMusic == true)
{
Item3->setNormalSpriteFrame(cache->spriteFrameByName("pause-music.png"));
// Item3->setSelectedSpriteFrame(cache->spriteFrameByName("close-pause-music.png"));
}
else
{
Item3->setNormalSpriteFrame(cache->spriteFrameByName("close-pause-music.png"));
//Item3->setSelectedSpriteFrame(cache->spriteFrameByName("pause-music.png"));
}
Item3->initWithTarget(this,menu_selector(LevelGame05::musicCallback));
Item3->setPosition(ccp(size.width*0.5+300, size.height*0.5));
Item3->setTag(127);
CCMenu* menu= CCMenu::create(Item1,Item2,Item3, NULL);
menu->setPosition(CCPointZero);
menu->setTag(128);
layer->addChild(menu);
this->addChild(layer,2);
}
示例2: init
bool TupianBrowserLayer::init() {
if (!CCLayerColor::initWithColor(ccc4(0, 0, 0, 127), W_SIZE.width, W_SIZE.height)) {
return false;
}
this->setMainTupianSprite(true);
CCSprite* x=CCSprite::create("cha.png");
x->setScale(1.5);
CCMenuItemSprite* xItem=CCMenuItemSprite::create(x, x, this, menu_selector(TupianBrowserLayer::menuCallback));
xItem->setPosition(S_RM->getPositionWithName("tupian_close"));
CCMenu* menu=CCMenu::create(xItem,NULL);
menu->setPosition(CCPointZero);
menu->setTag(kTagMenu);
this->addChild(menu);
CCLayerColor *tableBg = CCLayerColor::create(ccc4(0, 0, 0, 180),W_SIZE.width,220);
tableBg->setPosition(CCPointZero);
tableBg->setTag(kTagTupianTableLayer);
this->addChild(tableBg);
TupianTablePosition tupianTablePosition=TupianTablePosition("tupian_table","tupian_table_size","tupian_table_cell_size","xiezi_Tupian_table_cell_thumb_size","xiezi_Tupiankuang_in_cell","xiezi_Tupianthumb_in_cell",kCCScrollViewDirectionHorizontal);
m_tupianTabelLayer=TupianTableLayer::create(this,kTupian,m_tupian,tupianTablePosition);
m_tupianTabelLayer->setPosition(ccp(0, 4));
tableBg->setPosition(ccp(0,-280));
tableBg->addChild(m_tupianTabelLayer);
m_isTableShow=false;
//打开android按键响应
this->setKeypadEnabled(true);
return true;
}
示例3: tableCellAtIndex
CCTableViewCell* RequestList::tableCellAtIndex(CCTableView *table, unsigned int idx)
{
int index = idx;
EziFBIncomingRequest* fbRequest = (EziFBIncomingRequest*)_fbIncomingRequestList->objectAtIndex(index);
EziFacebookFriend* sender = fbRequest->getSender();
const char* senderName = sender->getName();
// Create the fancy test.
EziSocialWrapperNS::FB_REQUEST::TYPE requestType = fbRequest->getRequestType();
std::string messageToDisplay = "";
switch (requestType)
{
case EziSocialWrapperNS::FB_REQUEST::REQUEST_INVITE:
messageToDisplay.append(senderName).append(" has sent invitation to you.");
break;
case EziSocialWrapperNS::FB_REQUEST::REQUEST_GIFT:
messageToDisplay.append(senderName).append(" has sent gift to you.");
break;
case EziSocialWrapperNS::FB_REQUEST::REQUEST_CHALLENGE:
messageToDisplay.append(senderName).append(" has challenged to you.");
break;
default:
messageToDisplay.append("Unknown message");
break;
}
// Means users have already used this request.
bool requestConsumed = fbRequest->isConsumed();
CCSprite* profilePic = NULL;
ccColor4B bgColor = ccc4(20, 0, 40, 255);
if (requestConsumed == false)
{
bgColor = ccc4(50, 50, 20, 255);
}
// Build the table cell.
CCTableViewCell *cell = table->dequeueCell();
if (cell == NULL)
{
cell = new CCTableViewCell();
cell->autorelease();
// Create the back layer of the cell.
CCLayerColor* colorLayer = CCLayerColor::create(bgColor, SCREEN_WIDTH, CELL_HEIGHT);
colorLayer->setTag(BACKGROUND_TAG);
cell->addChild(colorLayer);
// Get the sender profile picture path. Create it if path is available.
if (sender != NULL && strcmp(sender->getPhotoPath(), "") != 0)
{
const char* picPath = sender->getPhotoPath();
profilePic = CCSprite::create(picPath);
}
else
{
profilePic = CCSprite::create(FB_DEFAULT_PHOTO);
}
// Add the profile pic to the cell row.
profilePic->setAnchorPoint(ccp(0, 0.5));
profilePic->setPosition(ccp(20, CELL_HEIGHT/2));
cell->addChild(profilePic);
profilePic->setTag(FRIEND_PHOTO_TAG);
// Set the message.
CCLabelTTF *messageLabel = CCLabelTTF::create(messageToDisplay.c_str(), "Helvetica", 20.0 * MENU_FONT_SCALE);
messageLabel->setAnchorPoint(ccp(0, 0.5));
messageLabel->setPosition(ccp(20 + 20 + profilePic->getContentSize().width, CELL_HEIGHT/2));
messageLabel->setTag(REQUEST_MESSAGE_LABEL_TAG);
messageLabel->setDimensions(CCSizeMake(SCREEN_WIDTH - (profilePic->getContentSize().width * 2) - 60, CELL_HEIGHT-5));
messageLabel->setHorizontalAlignment(kCCTextAlignmentLeft);
cell->addChild(messageLabel);
CCMenuItemImage* constumeItemButton = NULL;
constumeItemButton = CCMenuItemImage::create("use.png", "use_pressed.png");
constumeItemButton->setTag(idx);
constumeItemButton->setTarget(this, menu_selector(RequestList::useItem));
constumeItemButton->setScale(SCALE_FACTOR * 0.8);
constumeItemButton->setTag(FRIEND_CONSUME_BUTTON_TAG);
CCMenu* consumeMenu = CCMenu::create(constumeItemButton, NULL);
consumeMenu->setTag(FRIEND_CONSUME_MENU_TAG);
consumeMenu->setPosition(ccp(SCREEN_WIDTH - (constumeItemButton->getContentSize().width*SCALE_FACTOR*0.4),
(CELL_HEIGHT - (constumeItemButton->getContentSize().height)*SCALE_FACTOR*0.4)));
cell->addChild(consumeMenu);
//.........这里部分代码省略.........
示例4: ccp
//创建一个对应的简单的button,代表具体的章
CCLayerColor *SGSpecialBattleLayer::createChapButton(int buttonTag, SpecialBattleData *data)
{
CCLayerColor *layerColor = CCLayerColor::create(ccc4(0, 255, 0, 0), 160, 160);
layerColor->setTag(111);
layerColor->setAnchorPoint(ccp(0.5, 0.5));
if (data)
{
CCSprite *headIcon = SGDrawCards::createPureSprite(data->itemId, data->itemType, sg_specialBattleLayer);
CCSprite *borderIcon = CCSprite::createWithSpriteFrameName("equipPinzhi_5_0.png");
headIcon->addChild(borderIcon, 1);
borderIcon->setPosition(ccpAdd(ccp(headIcon->getContentSize().width / 2, headIcon->getContentSize().height / 2), ccp(0, 0)));
CCSprite *headIcon1 = SGDrawCards::createPureSprite(data->itemId, data->itemType, sg_specialBattleLayer);
CCSprite *borderIcon1 = CCSprite::createWithSpriteFrameName("equipPinzhi_5_0.png");
headIcon1->addChild(borderIcon1, 1);
borderIcon1->setPosition(ccpAdd(ccp(headIcon1->getContentSize().width / 2, headIcon1->getContentSize().height / 2), ccp(0, 0)));
//章节的按钮
SGButton *chapButton = SGButton::createFromSprite(headIcon, headIcon1, this, menu_selector(SGSpecialBattleLayer::enterSpBattleSection));
chapButton->setTag(buttonTag);
//章节的名称 //250 197 68
SGCCLabelTTF *chapNameTTF = SGCCLabelTTF::create(data->chapName.c_str(), FONT_PANGWA, 24);
chapButton->addChild(chapNameTTF, 2);
chapNameTTF->setInsideColor(ccc3(250, 197, 68));
chapNameTTF->setPosition(ccpAdd(ccp(chapNameTTF->getContentSize().width / 2, chapNameTTF->getContentSize().height / 3.5), ccp(0, 0)));
//如果没有开启,蒙灰
if (!data->isOpen)
{
CCSprite *greyMask = CCSprite::createWithSpriteFrameName("sp_battle_entry_mask.png");
greyMask->setOpacity(150);
chapButton->addChild(greyMask, 10);
greyMask->setPosition(ccpAdd(ccp(greyMask->getContentSize().width / 2 - 5, greyMask->getContentSize().height / 2 - 5), ccp(0, 0)));
//未开启,不可用
chapButton->setEnabled(false);
}
CCMenu *menu = CCMenu::create();
menu->setTouchPriority(10);
menu->setPosition(CCPointZero);
menu->addChild(chapButton);
layerColor->addChild(menu);
chapButton->setPosition(ccpAdd(ccp(0, 0), ccp(layerColor->getContentSize().width / 2, layerColor->getContentSize().height / 1.5)));
//显示描述的背景
CCSprite *descBg = CCSprite::createWithSpriteFrameName("sp_battle_infobg.png");
layerColor->addChild(descBg, 1);
descBg->setPosition(ccpAdd(chapButton->getPosition(), ccp(0, -descBg->getContentSize().height / 2 - chapButton->getContentSize().height / 1.7)));
//下方对应的描述
std::string desc;
if (data->isOpen)
{
desc = data->chapOpenDesc;
//如果是开启的,加上光效
ResourceManager::sharedInstance()->bindTexture("animationFile/ms_niubility.plist", RES_TYPE_LAYER_UI, sg_specialBattleLayer);
CCSpriterX *newRewardEffect = CCSpriterX::create("animationFile/ms_niubility.scml", true, true);
layerColor->addChild(newRewardEffect, -1);
newRewardEffect->setanimaID(0);
newRewardEffect->setisloop(true);
newRewardEffect->setScale(1.15);
newRewardEffect->setPosition(ccpAdd(chapButton->getPosition(), ccp(0, 0)));
newRewardEffect->play();
}
else
{
desc = data->chapClosedDesc;
}
SGCCLabelTTF *chapDescTTF = SGCCLabelTTF::create(desc.c_str(), FONT_PANGWA, 21);
descBg->addChild(chapDescTTF, 1);
chapDescTTF->setPosition(ccpAdd(ccp(descBg->getContentSize().width / 2, descBg->getContentSize().height / 2), ccp(0, 0)));
//如果开启状态,显示剩余次数
if (data->isOpen)
{
SGCCLabelTTF *residueTimeTTF = SGCCLabelTTF::create(CCString::createWithFormat(str_SpecailBattleResidueCoint, data->freePlayTimes)->getCString(), FONT_PANGWA, 20);
residueTimeTTF->setInsideColor(ccGREEN);
layerColor->addChild(residueTimeTTF, 1);
residueTimeTTF->setPosition(ccpAdd(descBg->getPosition(), ccp(0, -residueTimeTTF->getContentSize().height * 1.2)));
}
}
else
{
//没有的,直接问号显示
SGButton *chapButton = SGButton::create("sp_battle_unlock.png", "equipPinzhi_5_0.png", this, NULL);
chapButton->setEnabled(false);
layerColor->addChild(chapButton);
chapButton->setPosition(ccpAdd(ccp(0, 0), ccp(layerColor->getContentSize().width / 2, layerColor->getContentSize().height / 1.5)));
//.........这里部分代码省略.........