本文整理汇总了C++中CCLabelTTF::setTag方法的典型用法代码示例。如果您正苦于以下问题:C++ CCLabelTTF::setTag方法的具体用法?C++ CCLabelTTF::setTag怎么用?C++ CCLabelTTF::setTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCLabelTTF
的用法示例。
在下文中一共展示了CCLabelTTF::setTag方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CCTableViewCell
CCTableViewCell* S3PracticeScene::tableCellAtIndex(CCTableView *table, unsigned int idx)
{
// CCString *strCell = CCString::createWithFormat("Practice %d",idx);
CCString *strCell = CCString::create(aVectorCellValue[idx].c_str());
CCTableViewCell *pCell = table->dequeueCell();
if (!pCell) {
pCell = new CCTableViewCell();
pCell->autorelease();
CCSprite *pSprite = CCSprite::create();//("cellLine.png");
pSprite->setAnchorPoint(CCPointZero);
pSprite->setPosition(CCPointZero);
pCell->addChild(pSprite);
{
CCLabelTTF *pLabel = CCLabelTTF::create(strCell->getCString(), "Arial", s3FontSize3_macro, s3Size2_macro(aCell), kCCTextAlignmentLeft, kCCVerticalTextAlignmentCenter);
pLabel->setPosition(ccp(s3Less2_macro,0));
pLabel->setAnchorPoint(CCPointZero);
pLabel->setColor(ccc3(0,0,0));
pLabel->setTag(10);
pCell->addChild(pLabel,1);
}
{
CCLabelTTF *pLabel = CCLabelTTF::create("Locked", "Arial",s3FontSize3_macro, s3SizeCellLaterLabel_macro, kCCTextAlignmentRight, kCCVerticalTextAlignmentCenter);
pLabel->setPosition(s3Position8_macro(aItem));
pLabel->setAnchorPoint(CCPointZero);
pLabel->setColor(ccc3(0,0,255));
pLabel->setTag(10);
pCell->addChild(pLabel,1);
}
}
CCLabelTTF *pLabel = (CCLabelTTF*)pCell->getChildByTag(10);
pLabel->setString(strCell->getCString());
return pCell;
}
示例2: onEnter
void EffectAdvanceTextLayer::onEnter(void)
{
CCLayer::onEnter();
CCSprite *bg = CCSprite::create("Images/background3.png");
addChild(bg, 0, kTagBackground);
bg->setPosition( VisibleRect::center() );
CCSprite* grossini = CCSprite::create("Images/grossinis_sister2.png");
bg->addChild(grossini, 1, kTagSprite1);
grossini->setPosition( ccp(VisibleRect::left().x+VisibleRect::getVisibleRect().size.width/3.0f, VisibleRect::bottom().y+ 200) );
CCActionInterval* sc = CCScaleBy::create(2, 5);
CCActionInterval* sc_back = sc->reverse();
grossini->runAction( CCRepeatForever::create( (CCActionInterval*)(CCSequence::create(sc, sc_back, NULL)) ) );
CCSprite* tamara = CCSprite::create("Images/grossinis_sister1.png");
bg->addChild(tamara, 1, kTagSprite2);
tamara->setPosition( ccp(VisibleRect::left().x+2*VisibleRect::getVisibleRect().size.width/3.0f,VisibleRect::bottom().y+200) );
CCActionInterval* sc2 = CCScaleBy::create(2, 5);
CCActionInterval* sc2_back = sc2->reverse();
tamara->runAction( CCRepeatForever::create( (CCActionInterval*)(CCSequence::create(sc2, sc2_back, NULL)) ) );
CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Marker Felt", 28);
label->setPosition( ccp(VisibleRect::center().x,VisibleRect::top().y-80) );
addChild(label);
label->setTag( kTagLabel );
std::string strSubtitle = subtitle();
if( ! strSubtitle.empty() )
{
CCLabelTTF* l = CCLabelTTF::create(strSubtitle.c_str(), "Thonburi", 16);
addChild(l, 101);
l->setPosition( ccp(VisibleRect::center().x,VisibleRect::top().y-80) );
}
CCMenuItemImage *item1 = CCMenuItemImage::create("Images/b1.png", "Images/b2.png", this, menu_selector(EffectAdvanceTextLayer::backCallback) );
CCMenuItemImage *item2 = CCMenuItemImage::create("Images/r1.png","Images/r2.png", this, menu_selector(EffectAdvanceTextLayer::restartCallback) );
CCMenuItemImage *item3 = CCMenuItemImage::create("Images/f1.png", "Images/f2.png", this, menu_selector(EffectAdvanceTextLayer::nextCallback) );
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
menu->setPosition(CCPointZero);
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
addChild(menu, 1);
}
示例3: initWithColor
TextLayer::TextLayer(void)
{
initWithColor( ccc4(32,128,32,255) );
CCNode* node = CCNode::create();
CCActionInterval* effect = getAction();
node->runAction(effect);
addChild(node, 0, kTagBackground);
CCSprite *bg = CCSprite::create(s_back3);
node->addChild(bg, 0);
// bg->setAnchorPoint( CCPointZero );
bg->setPosition(VisibleRect::center());
CCSprite* grossini = CCSprite::create(s_pPathSister2);
node->addChild(grossini, 1);
grossini->setPosition( ccp(VisibleRect::left().x+VisibleRect::getVisibleRect().size.width/3,VisibleRect::center().y) );
CCActionInterval* sc = CCScaleBy::create(2, 5);
CCActionInterval* sc_back = sc->reverse();
grossini->runAction( CCRepeatForever::create(CCSequence::create(sc, sc_back, NULL) ) );
CCSprite* tamara = CCSprite::create(s_pPathSister1);
node->addChild(tamara, 1);
tamara->setPosition( ccp(VisibleRect::left().x+2*VisibleRect::getVisibleRect().size.width/3,VisibleRect::center().y) );
CCActionInterval* sc2 = CCScaleBy::create(2, 5);
CCActionInterval* sc2_back = sc2->reverse();
tamara->runAction( CCRepeatForever::create(CCSequence::create(sc2, sc2_back, NULL)) );
CCLabelTTF* label = CCLabelTTF::create((effectsList[actionIdx]).c_str(), "Marker Felt", 32);
label->setPosition( ccp(VisibleRect::center().x,VisibleRect::top().y-80) );
addChild(label);
label->setTag( kTagLabel );
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(TextLayer::backCallback) );
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(TextLayer::restartCallback) );
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(TextLayer::nextCallback) );
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
menu->setPosition(CCPointZero);
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
addChild(menu, 1);
schedule( schedule_selector(TextLayer::checkAnim) );
}
示例4: beginCountdown
void GameLayer::beginCountdown(int second) {
preCountdown();
setCountdownNum(second);
CCSize size = CCDirector::sharedDirector()->getWinSize();
CCLabelTTF *label = CCLabelTTF::create(CCString::createWithFormat("%d", getCountdownNum())->getCString(), "ArialMT", 100);
label->setColor(ccRED);
label->setAnchorPoint(ccp(.5, .5));
label->setPosition(ccp(size.width * .5, size.height * .5));
this->addChild(label, ZORDER_COUNTDOWN);
this->schedule(schedule_selector(GameLayer::countdownSeconds), 0.8);
label->setTag(TagCountdown);
doCountdownAnimation(label);
}
示例5: tableCellAtIndex
CCTableViewCell* RankingScene::tableCellAtIndex(CCTableView *table, unsigned int idx) {
CCSize size = CCDirector::sharedDirector()->getWinSize();
CCTableViewCell *cell = table->dequeueCell();
cell = new CCTableViewCell();
cell->autorelease();
// Player Point
Player * p = (Player*)players->objectAtIndex(idx);
CCString *string = CCString::createWithFormat("%d",p->getPoint());
CCLabelTTF *Pointlabel = CCLabelTTF::create(string->getCString(), "Helvetica", 40);
Pointlabel->setAnchorPoint(ccp(1, 0));
Pointlabel->setPosition(ccp(600,0));
Pointlabel->setTag(123);
cell->addChild(Pointlabel);
// Player Name
std::string name = p->getName();
CCLabelTTF *Namelabel = CCLabelTTF::create(p->getName().c_str(), "Helvetica", 40);
Namelabel->setAnchorPoint(CCPointZero);
Namelabel->setPosition(ccp(60, 0));
cell->addChild(Namelabel);
// Player Rank
char rankBuf[3];
sprintf(rankBuf, "Numbers/%i.png", idx+1);
CCSprite *rank = CCSprite::create(rankBuf);
rank->setAnchorPoint(CCPointZero);
rank->setPosition(CCPointZero);
cell->addChild(rank);
if (idx == 0) {
int rewardLocal = GameManager::sharedGameManager()->getReward();
std::string nameLocal = GameManager::sharedGameManager()->getName();
int pointMax = CCUserDefault::sharedUserDefault()->getIntegerForKey("pointMax");
if (p->getReward() != 0 && rewardLocal != 0 &&
p->getName() == nameLocal && p->getPoint() == pointMax) {
CCMenuItemImage *bt_send_email =
CCMenuItemImage::create("Present.png","PresentOnClicked.png",
this, menu_selector(RankingScene::reward));
CCMenu * menu = CCMenu::create(bt_send_email, NULL);
menu->setPosition(ccp(550, 30));
cell->addChild(menu);
}
}
return cell;
}
示例6: showGametimeLabel
void MainGameScene::showGametimeLabel()
{
CCString* timeString = CCString::createWithFormat("%8.3f",gameTime);
CCLabelTTF* timerLabel = (CCLabelTTF*)this->getChildByTag(tagGametimeLabel);
if(timerLabel){
timerLabel->setString(timeString->getCString());
}else{
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
timerLabel = CCLabelTTF::create(timeString->getCString(), "Arial", 40.0);
timerLabel->setPosition(ccp(winSize.width * 0.8, winSize.height * 0.9));
timerLabel->setColor(ccc3(0, 0, 0));
timerLabel->setTag(tagGametimeLabel);
this->addChild(timerLabel);
}
}
示例7: refreshWorldPad
void GamePan::refreshWorldPad()
{
CCNode* pBaseNode = m_pCcbNode->getChildByTag(kTagGamePanWordPan);
CCNode* tabNode = pBaseNode->getChildByTag(kTagGamePanWordPanTabBase);
CCNode* itemNode = pBaseNode->getChildByTag(kTagGamePanWordPanItemBase);
CCLabelTTF* itemTemp = dynamic_cast<CCLabelTTF*>(itemNode->getChildByTag(kTagGamePanWordPanItemTitle));
CCControlButton* tabItem = dynamic_cast<CCControlButton*>(tabNode->getChildByTag(kTagGamePanWordPanTabBaseItem));
float itemWidth = tabItem->getContentSize().width+ITEM_SPACE;
float itemHeight = tabItem->getContentSize().height+ITEM_SPACE;
for(int i =0;i<MAX_LINE;i++)
{
for(int j =0;j<MAX_ROW;j++)
{
CCControlButton* item = CCControlButton::create();
Utils::copyCCControlButton(item,tabItem);
item->setPosition(ccp(tabItem->getPositionX()+j*itemWidth,tabItem->getPositionY()-i*itemHeight));
item->setTag(j+i*MAX_ROW);
tabNode->addChild(item);
CCLabelTTF* title = Utils::copyCCLabelTTF(itemTemp);
title->setPosition(item->getPosition());
title->setTag(j+i*MAX_ROW);
itemNode->addChild(title);
CCString* str = (CCString*)_wordList->randomObject();
title->setString(str->getCString());
_wordList->removeObject(str);
}
}
for(int i =0;i<MAX_LINE;i++)
{
for(int j =0;j<MAX_ROW;j++)
{
CCControlButton* item = dynamic_cast<CCControlButton*>(tabNode->getChildByTag(j+i*MAX_ROW));
XCheckBox* pCheckBox = XCheckBox::create(item);
pCheckBox->setTag(item->getTag());
pCheckBox->setToggle(false);
pCheckBox->setTarget(this, cccontrol_selector(GamePan::wordSelectCallbackCCControl));
tabNode->addChild(pCheckBox);
item->removeFromParent();
}
}
itemTemp->removeFromParent();
tabItem->removeFromParent();
refreshLetter();
}
示例8: showMinimamCount
void MainGameScene::showMinimamCount()
{
CCString* minCountString = CCString::createWithFormat("MIN:%d",minimamCount);
CCLabelTTF* minCountLabel = (CCLabelTTF*)this->getChildByTag(tagMinimamCountLabel);
if(minCountLabel){
minCountLabel->setString(minCountString->getCString());
}else{
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
minCountLabel = CCLabelTTF::create(minCountString->getCString(), "Arial", 40.0);
minCountLabel->setPosition(ccp(winSize.width * 0.8, winSize.height * 0.8));
minCountLabel->setColor(ccc3(0, 0, 0));
minCountLabel->setTag(tagGametimeLabel);
this->addChild(minCountLabel);
}
}
示例9: addScoreAnimation
void BaseBug::addScoreAnimation()
{
CCString *str = CCString::createWithFormat("+%d", EACH_BUG_SCORE);
CCLabelTTF* textStr = CCLabelTTF::create(str->getCString(), "Arial", 40);
textStr->setPosition(ccp(this->getPositionX(), this->getPositionY()+40));
textStr->setColor(ccRED);
this->getParent()->addChild(textStr);
textStr->setTag(TAG_BUG_SCORE);
CCActionInterval* action = CCMoveTo::create(0.8f, CCPointMake(this->getPositionX(), this->getPositionY()+80));
CCActionInterval* fadeOut = CCFadeOut::create(0.8f);
CCFiniteTimeAction* action2 = CCSequence::create(CCMoveTo::create(0.8f, CCPointMake(this->getPositionX(), this->getPositionY()+80)),
CCCallFunc::create(this, callfunc_selector(BaseBug::scoreAnimationEnd)),
NULL);
CCAction* act = CCSpawn::create( fadeOut, action2, NULL);
textStr->runAction(act);
}
示例10: tableCellAtIndex
CCTableViewCell * equipmentRoom:: tableCellAtIndex (CCTableView * table, unsigned int idx)
{
CCString* string;
char tc_label[30];
int contentID = 0;
sprintf(tc_label,"%s", equipmentList[idx]->m_name.c_str());
//string = CCString::create(m_buttons[idx].label);
string = CCString::create(tc_label);
//cout << idx << "script name = " << string->getCString() << endl;
//cout << "author1 = " << scriptVector[idx]->authorNames[0] << endl;
CCTableViewCell *cell;// = table->dequeueCell();
//if (!cell) {
cell = new CustomTableViewCell();
cell->autorelease();
CCSprite *sprite = CCSprite::create("grey_cell.png");
sprite->setAnchorPoint(CCPointZero);
sprite->setPosition(ccp(0, 0));
sprite->setScaleX(sfx);
sprite->setScaleY(sfy);
sprite->setTag(4);
cell->addChild(sprite);
cell->setObjectID(idx);
CCLabelTTF *label = CCLabelTTF::create(string->getCString(), "Helvetica", 12.0);
label->setPosition(ccp(sprite->boundingBox().size.width/2, sprite->boundingBox().size.height/2));
label->setAnchorPoint(ccp(0.5, 0.5));
//label->setPosition(CCPointZero);
//label->setAnchorPoint(CCPointZero);
label->setTag(123);
cell->addChild(label);
//}
/*else
{
CCLabelTTF *label = (CCLabelTTF*)cell->getChildByTag(123);
label->setString(string->getCString());
}*/
cout << "cell # " << idx << "title = " << string->getCString() << endl;
return cell;
}
示例11: CCTableViewCell
CCTableViewCell * HelloWorld::tableCellAtIndex(cocos2d::extension::CCTableView *table, unsigned int idx){
CCTableViewCell *cell = table->dequeueCell();
CCLabelTTF *label;
if (cell==NULL) {
cell = new CCTableViewCell();
label = CCLabelTTF::create("Label", "Courier", 48);
cell->addChild(label);
label->setTag(TABLE_CELL_LABEL_TAG);
label->setAnchorPoint(ccp(0, 0));
cell->setAnchorPoint(ccp(0, 0));
}else{
label = (CCLabelTTF*)cell->getChildByTag(TABLE_CELL_LABEL_TAG);
}
label->setString(((CCString*)dataArr->objectAtIndex(idx))->getCString());
return cell;
}
示例12: showHighScoreLabel
void GameScene::showHighScoreLabel() {
CCUserDefault* userDefault = CCUserDefault::sharedUserDefault();
const char* highScorekey = "hightscore";
float highScore = userDefault->getFloatForKey(highScorekey, 99.9);
if (gametime != 0)
{
if (gametime > highScore)
{
return;
}
else
{
highScore = gametime;
userDefault->setFloatForKey(highScorekey, highScore);
userDefault->flush();
}
}
const int tagHighScoreLabel = 200;
CCString* highScoreString = CCString::createWithFormat("%8.1fs", highScore);
CCLabelTTF* highScoreLabel = (CCLabelTTF*)this->getChildByTag(tagHighScoreLabel);
if (highScoreLabel)
{
highScoreLabel->setString(highScoreString->getCString());
}
else
{
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
highScoreLabel = CCLabelTTF::create(highScoreString->getCString(), "Arial", 24.0);
highScoreLabel->setPosition(ccp(winSize.width*0.9, winSize.height*0.7));
highScoreLabel->setTag(tagHighScoreLabel);
this->addChild(highScoreLabel);
}
}
示例13: checkForGoal
void StadionLayer::checkForGoal(Player* player, Player* opponent, CCLabelTTF* label)
{
CCPoint ballCenter = ccp(_ball->getPosition().x, _ball->getPosition().y);
if (player->getGate()->getHoldsBall())
{
bool isGoal = false;
isGoal = ballCenter.x > (player->getGate()->getPosition().x -
player->getGate()->getContentSize().width * 0.5f);
if (isGoal)
{
_gameState = kGamePaused;
int score = opponent->getScore();
score++;
opponent->setScore(score);
updateScoreLabel(label, score);
player->getGate()->setHoldsBall(false);
int goals = sgl_Settings.getOptions().Score;
if (opponent->getScore() >= goals)
{
SimpleAudioEngine::sharedEngine()->playBackgroundMusic(CROWD_SOUND, false);
_goalAd->setVisible(true);
}
else
{
SimpleAudioEngine::sharedEngine()->playBackgroundMusic(CROWD_SOUND, false);
CCLabelTTF* won = CCLabelTTF::create(getRightControl()->getPlayerName().c_str(), S_F_TYPE.c_str(), 100);
won->setTag(_gameWonSpriteTag);
addChild(won);
_gameState = kGameOver;
}
_ball->reset();
}
}
}
示例14: showGametimeLabel
void GameScene::showGametimeLabel()
{
const int tagGametimeLabel = 100;
CCString* timeString = CCString::createWithFormat("%8.1fs", gametime);
CCLabelTTF* timerLabel = (CCLabelTTF*)this->getChildByTag(tagGametimeLabel);
if (timerLabel) {
timerLabel->setString(timeString->getCString());
}
else
{
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
timerLabel = CCLabelTTF::create(timeString->getCString(), "Arial", 24.0);
timerLabel->setPosition(ccp(winSize.width*0.9, winSize.height*0.9));
timerLabel->setTag(tagGametimeLabel);
this->addChild(timerLabel);
}
}
示例15: init
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !CCLayer::init() )
{
return false;
}
this->setTouchEnabled(true);
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
PathObject *p01 = new PathObject(ccp(100, 50), ccp(240, 50));
PathObject *p02 = new PathObject(ccp(240, 50), ccp(400, 200));
PathObject *p03 = new PathObject(ccp(400, 200), ccp(200, 150));
PathObject *p04 = new PathObject(ccp(200, 150), ccp(350, 280));
PathObject *p05 = new PathObject(ccp(350, 280), ccp(150, 300));
PathObject *p06 = new PathObject(ccp(150, 300), ccp(100, 50));
pathArray = CCArray::create();
pathArray->retain();
pathArray->addObject(p01);
pathArray->addObject(p02);
pathArray->addObject(p03);
pathArray->addObject(p04);
pathArray->addObject(p05);
pathArray->addObject(p06);
region = new RegionObject(pathArray);
//Add a label to show the position
CCLabelTTF *label = CCLabelTTF::create("", "Verdana-BoldItalic", 15);
label->setColor(ccWHITE);
label->setTag(999);
this->addChild(label);
return true;
}