本文整理汇总了C++中CCLabelTTF类的典型用法代码示例。如果您正苦于以下问题:C++ CCLabelTTF类的具体用法?C++ CCLabelTTF怎么用?C++ CCLabelTTF使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CCLabelTTF类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CCSizeMake
//------------------------------------------------------------------
//
// LabelTTFTest
//
//------------------------------------------------------------------
LabelTTFTest::LabelTTFTest()
{
CCSize s = CCDirector::sharedDirector()->getWinSize();
// CCLabelBMFont
CCLabelTTF *left = CCLabelTTF::labelWithString("align left", CCSizeMake(s.width, 50), CCTextAlignmentLeft, "Marker Felt", 32);
CCLabelTTF *center = CCLabelTTF::labelWithString("align center", CCSizeMake(s.width, 50), CCTextAlignmentCenter, "Marker Felt", 32);
CCLabelTTF *right = CCLabelTTF::labelWithString("align right", CCSizeMake(s.width, 50), CCTextAlignmentRight, "Marker Felt", 32);
left->setPosition(ccp(s.width / 2, 200));
center->setPosition(ccp(s.width / 2, 150));
right->setPosition(ccp(s.width / 2, 100));
addChild(left);
addChild(center);
addChild(right);
}
示例2: init
// on "init" you need to initialize your instance
bool MainScene::init()
{
//////////////////////////////
// 1. super init first
if ( !CCLayer::init() )
{
return false;
}
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
CCSprite* bgSprite = CCSprite::create("img_direct.jpg");
bgSprite->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
this->addChild(bgSprite);
CCLabelTTF* pLabelTitle = CCLabelTTF::create("SOOMLA Store\nExample", "GoodDog.otf", 54);
pLabelTitle->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height - 100 + origin.y));
this->addChild(pLabelTitle, 1);
CCLabelTTF* pLabelGame = CCLabelTTF::create("[YOUR GAME HERE]", "GoodDog.otf", 54);
pLabelGame->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 - 0 + origin.y));
this->addChild(pLabelGame, 1);
pRightBox = CCSprite::create("right_bg.png");
pRightBox->setScale(2.0f);
pRightBox->setPosition(ccp(origin.x + visibleSize.width - (pRightBox->boundingBox().size.width / 2) - 50, 250 + origin.y));
this->addChild(pRightBox, 0);
Soomla* pSoomla = Soomla::create("soomla_logo_new.png", pRightBox);
pSoomla->setScale(2.0f);
pSoomla->setPosition(ccp(origin.x + (pSoomla->boundingBox().size.width / 2) + 50, 250 + origin.y));
this->addChild(pSoomla, 0);
CCLabelTTF* pLabelInstructions = CCLabelTTF::create("Drag the SooMLA-bot to the box top open store", "GoodDog.otf", 24);
pLabelInstructions->setPosition(ccp(visibleSize.width/2 + origin.x, 100 + origin.y));
this->addChild(pLabelInstructions, 1);
this->setKeypadEnabled(true);
return true;
}
示例3: onTextFieldInsertText
bool TextFieldTTFActionTest::onTextFieldInsertText(CCTextFieldTTF * pSender, const char * text, int nLen)
{
// if insert enter, treat as default to detach with ime
if ('\n' == *text)
{
return false;
}
// if the textfield's char count more than m_nCharLimit, doesn't insert text anymore.
if (pSender->getCharCount() >= m_nCharLimit)
{
return true;
}
// create a insert text sprite aScut do some action
CCLabelTTF * label = CCLabelTTF::create(text, FONT_NAME, FONT_SIZE);
this->addChild(label);
ccColor3B color = { 226, 121, 7};
label->setColor(color);
// move the sprite from top to position
CCPoint endPos = pSender->getPosition();
if (pSender->getCharCount())
{
endPos.x += pSender->getContentSize().width / 2;
}
CCSize inputTextSize = label->getContentSize();
CCPoint beginPos(endPos.x, CCDirector::sharedDirector()->getWinSize().height - inputTextSize.height * 2);
float duration = 0.5;
label->setPosition(beginPos);
label->setScale(8);
CCAction * seq = CCSequence::create(
CCSpawn::create(
CCMoveTo::create(duration, endPos),
CCScaleTo::create(duration, 1),
CCFadeOut::create(duration),
0),
CCCallFuncN::create(this, callfuncN_selector(TextFieldTTFActionTest::callbackRemoveNodeWhendidAction)),
0);
label->runAction(seq);
return false;
}
示例4: setLeftBgString
void IOSStoreLayer::setLeftBgString(const char* charString)
{
if (CCNode* pnode = m_pKaibaoxiangNode->getChildByTag(leftbg_tag))
{
CCLabelTTF* pLable = (CCLabelTTF*)pnode->getChildByTag(leftbg_string_tag);
if (pLable)
{
pLable->setString(charString);
if (m_enumComeFrom == from_SeasonSelector)
{
pLable->setPosition(ccp(pLable->getPositionX(), 198));
}
else if (m_enumComeFrom == from_MarketStore)
{
pLable->setPosition(ccp(pLable->getPositionX(), 188));
}
}
}
}
示例5: CC_BREAK_IF
// on "init" you need to initialize your instance
bool PPMainMenuLayer::init()
{
bool bRet = false;
do
{
//////////////////////////////////////////////////////////////////////////
// super init first
//////////////////////////////////////////////////////////////////////////
CC_BREAK_IF(! CCLayerColor::initWithColor( ccc4(240, 235, 239, 255) ) );
//////////////////////////////////////////////////////////////////////////
CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();
CCSize size = pEGLView->getVisibleSize();
CCLabelTTF* label = CCLabelTTF::create("JELLY", "Consolas", 40);
label->setColor( ccc3(0, 0, 0) );
label->setAnchorPoint( ccp(0.5, 0.5) );
label->setPosition( ccp(size.width / 2, size.height * 2 / 3) );
addChild(label);
PPCube* p = new PPCube( PPCube::PPCubeType_S );
p->setAnchorPoint( ccp(0.5, 0.5) );
p->setPosition( ccp( size.width / 2, (size.height * 2 / 3 - label->getContentSize().height) ) );
addChild(p);
p->release();
label = CCLabelTTF::create("Play", "Consolas", 20);
label->setColor( ccc3(0, 0, 0) );
CCMenuItemLabel* pMenuItem = CCMenuItemLabel::create(label, this, menu_selector(PPMainMenuLayer::MainMenuCallback));
CCMenu* pMenu =CCMenu::create(pMenuItem, NULL);
pMenu->setAnchorPoint( ccp(0.5, 0.5) );
pMenu->setPosition( ccp(size.width / 2, size.height / 4) );
addChild(pMenu);
bRet = true;
}
while (0);
return bRet;
}
示例6: CCTableViewCell
CCTableViewCell* MainScene::tableCellAtIndex(CCTableView *table, unsigned int idx)
{
CCString *string = CCString::createWithFormat("%d", idx);
CCTableViewCell *cell = table->dequeueCell();
if (!cell) {
cell = new CCTableViewCell();
cell->autorelease();
CCSprite *sprite = CCSprite::create("Icon-144.png");
sprite->setAnchorPoint(CCPointZero);
sprite->setPosition(ccp(0, 0));
sprite->setScaleX(2);
cell->addChild(sprite);
CCLabelTTF *label = CCLabelTTF::create(string->getCString(), "Helvetica", 20.0);
label->setPosition(CCPointZero);
label->setAnchorPoint(CCPointZero);
label->setTag(123);
cell->addChild(label);
CCMenuItemImage *pBtn = CCMenuItemImage::create(
"CloseNormal.png",
"CloseSelected.png",
this,
menu_selector(MainScene::tableViewSubBtnCallback));
CCMenu* pMenu = CCMenu::create(pBtn, NULL);
pBtn->setPosition(ccp(pBtn->getContentSize().width/2,pBtn->getContentSize().height/2));
pMenu->setPosition(CCPointZero);
cell->addChild(pMenu, 1);
cell->setTag(idx);
}
else
{
CCLabelTTF *label = (CCLabelTTF*)cell->getChildByTag(123);
label->setString(string->getCString());
}
return cell;
}
示例7: showGameCountLabel
void MainGameScene::showGameCountLabel()
{
CCString* countString = CCString::createWithFormat("%d",totalGameCount);
CCSprite* pTouchWaku = (CCSprite*)this->getChildByTag(tagTouchWaku);
if(pTouchWaku){
CCLabelTTF* countLabel = (CCLabelTTF*)pTouchWaku->getChildByTag(tagGameCountLavel);
if(countLabel){
countLabel->setString(countString->getCString());
return;
}
}else{
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
CCSprite* pTouchWaku= CCSprite::create("touch_waku.png");
pTouchWaku->setScale(0.5);
CCSize pTouchSize = pTouchWaku->getContentSize();
pTouchWaku->setPosition(ccp(winSize.width - pTouchSize.width * 0.4, winSize.height - pTouchSize.height * 0.4));
pTouchWaku->setTag(tagTouchWaku);
CCLabelTTF* countLabel;
countLabel = CCLabelTTF::create(countString->getCString(), "Arial", 80.0);
countLabel->setPosition(ccp(pTouchSize.width * 0.5, pTouchSize.height * 0.6));
countLabel->setColor(ccc3(0, 0, 0));
countLabel->setTag(tagGameCountLavel);
CCLabelTTF* countLabel2;
countLabel2 = CCLabelTTF::create("touch", "Arial", 50.0);
countLabel2->setPosition(ccp(pTouchSize.width * 0.5, pTouchSize.height * 0.3));
countLabel2->setColor(ccc3(0, 0, 0));
pTouchWaku->addChild(countLabel);
pTouchWaku->addChild(countLabel2);
this->addChild(pTouchWaku);
}
}
示例8: initWithText
bool GameButton::initWithText(const char * text, bool isBig)
{
if (!CCSprite::init()) {
return false;
}
CCString* btnFrame = (isBig) ? CCString::create("button_big.png") : CCString::create("button_small.png");
int fSize = 18 * Utils::getArtScaleFactor();
this->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(btnFrame->getCString()));
CCLabelTTF *label = CCLabelTTF::create(text, CCString::createWithFormat("%s.ttf",FONT_MAIN)->getCString(), fSize + isBig * fSize);
label->setPosition(ccp(this->getContentSize().width/2,this->getContentSize().height/2));
this->addChild(label,1);
CCLabelTTF *labelShadow = CCLabelTTF::create(text, CCString::createWithFormat("%s.ttf",FONT_MAIN)->getCString(), fSize + isBig * fSize);
labelShadow->setPosition(ccp(this->getContentSize().width/2 - (2 + isBig * 2),this->getContentSize().height/2));
labelShadow->setColor(ccBLACK);
labelShadow->setOpacity(150);
this->addChild(labelShadow,0);
this->setScale(Utils::getScale());
return true;
}
示例9: title
void ArmatureTestLayer::onEnter()
{
CCLayer::onEnter();
// add title and subtitle
std::string str = title();
const char *pTitle = str.c_str();
CCLabelTTF *label = CCLabelTTF::create(pTitle, "Arial", 18);
label->setColor(ccc3(0, 0, 0));
addChild(label, 1, 10000);
label->setPosition( ccp(VisibleRect::center().x, VisibleRect::top().y - 30) );
std::string strSubtitle = subtitle();
if( ! strSubtitle.empty() )
{
CCLabelTTF *l = CCLabelTTF::create(strSubtitle.c_str(), "Arial", 18);
l->setColor(ccc3(0, 0, 0));
addChild(l, 1, 10001);
l->setPosition( ccp(VisibleRect::center().x, VisibleRect::top().y - 60) );
}
// add menu
backItem = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(ArmatureTestLayer::backCallback) );
restartItem = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(ArmatureTestLayer::restartCallback) );
nextItem = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(ArmatureTestLayer::nextCallback) );
CCMenu *menu = CCMenu::create(backItem, restartItem, nextItem, NULL);
menu->setPosition(CCPointZero);
backItem->setPosition(ccp(VisibleRect::center().x - restartItem->getContentSize().width * 2, VisibleRect::bottom().y + restartItem->getContentSize().height / 2));
restartItem->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y + restartItem->getContentSize().height / 2));
nextItem->setPosition(ccp(VisibleRect::center().x + restartItem->getContentSize().width * 2, VisibleRect::bottom().y + restartItem->getContentSize().height / 2));
addChild(menu, 100);
setShaderProgram(CCShaderCache::sharedShaderCache()->programForKey(kCCShader_PositionTextureColor));
}
示例10: ccp
TestLayer2::TestLayer2()
{
float x,y;
CCSize size = CCDirector::sharedDirector()->getWinSize();
x = size.width;
y = size.height;
CCSprite* bg1 = CCSprite::create(s_back2);
bg1->setPosition( ccp(size.width/2, size.height/2) );
addChild(bg1, -1);
CCLabelTTF* title = CCLabelTTF::create((transitions[s_nSceneIdx]).c_str(), "Thonburi", 32 );
addChild(title);
title->setColor( ccc3(255,32,32) );
title->setPosition( ccp(x/2, y-100) );
CCLabelTTF* label = CCLabelTTF::create("SCENE 2", "Marker Felt", 38);
label->setColor( ccc3(16,16,255));
label->setPosition( ccp(x/2,y/2));
addChild( label);
// menu
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(TestLayer2::backCallback) );
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(TestLayer2::restartCallback) );
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(TestLayer2::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(TestLayer2::step), 1.0f);
}
示例11: CCPointMake
TestLayer2::TestLayer2()
{
float x,y;
CCSize size = CCDirector::sharedDirector()->getWinSize();
x = size.width;
y = size.height;
CCSprite* bg1 = CCSprite::spriteWithFile(s_back2);
bg1->setPosition( CCPointMake(size.width/2, size.height/2) );
addChild(bg1, -1);
CCLabelTTF* title = CCLabelTTF::labelWithString((transitions[s_nSceneIdx]).c_str(), "Thonburi", 32 );
addChild(title);
title->setColor( ccc3(255,32,32) );
title->setPosition( CCPointMake(x/2, y-100) );
CCLabelTTF* label = CCLabelTTF::labelWithString("SCENE 2", "Marker Felt", 38);
label->setColor( ccc3(16,16,255));
label->setPosition( CCPointMake(x/2,y/2));
addChild( label);
// menu
CCMenuItemImage *item1 = CCMenuItemImage::itemFromNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(TestLayer2::backCallback) );
CCMenuItemImage *item2 = CCMenuItemImage::itemFromNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(TestLayer2::restartCallback) );
CCMenuItemImage *item3 = CCMenuItemImage::itemFromNormalImage(s_pPathF1, s_pPathF2, this, menu_selector(TestLayer2::nextCallback) );
CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL);
menu->setPosition( CCPointZero );
item1->setPosition( CCPointMake( x/2 - 100,30) );
item2->setPosition( CCPointMake( x/2, 30) );
item3->setPosition( CCPointMake( x/2 + 100,30) );
addChild(menu, 1);
schedule(schedule_selector(TestLayer2::step), 1.0f);
}
示例12: if
CCTableViewCell* HelloWorld::tableCellAtIndex(CCTableView *table, unsigned int idx)
{
CCDictionary* pRecipe = (CCDictionary*)m_pRecipes->objectAtIndex(idx);
CCString* pName = (CCString*)pRecipe->objectForKey("name");
CCString* pNo = (CCString*)pRecipe->objectForKey("recipe");
CCString* pStep = (CCString*)pRecipe->objectForKey("step");
CCString* string;
if (pStep!=NULL) {
string = CCString::createWithFormat("レシピ %s (ステップ%s): %s", pNo->getCString(), pStep->getCString(), pName->getCString());
} else if (pNo->isEqual(CCString::create("0"))) {
string = pName;
} else {
string = CCString::createWithFormat("レシピ %s : %s", pNo->getCString(), pName->getCString());
}
CCTableViewCell *cell = table->dequeueCell();
if (!cell) {
cell = new CCTableViewCell();
cell->autorelease();
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
int fontSize = CCEGLView::sharedOpenGLView()->getDesignResolutionSize().height/320.0f * 20;
CCLabelTTF *label = CCLabelTTF::create(string->getCString(), "Helvetica", fontSize, CCSizeMake(visibleSize.width, visibleSize.height/5), kCCTextAlignmentCenter);
label->setPosition(CCPointZero);
label->setAnchorPoint(CCPointZero);
label->setTag(123);
cell->addChild(label);
}
else
{
CCLabelTTF *label = (CCLabelTTF*)cell->getChildByTag(123);
label->setString(string->getCString());
}
return cell;
}
示例13: ccc3
bool GameOverLayer::init()
{
if( !CCLayer::init() )
return false;
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
// add game over text in the middle of the screen with red color
CCLabelTTF *gameOverLabel = CCLabelTTF::create("GAME OVER", "Thonburi", 50);
gameOverLabel->setColor( ccc3(255, 0, 0) );
gameOverLabel->setPosition( ccp(winSize.width / 2, winSize.height / 2 + 50) );
this->addChild(gameOverLabel);
// add instruction below the game over text
CCLabelTTF *infoLabel = CCLabelTTF::create("touch to continue", "Thonburi", 20);
infoLabel->setColor( ccc3(255, 255, 255) );
infoLabel->setPosition( ccp(winSize.width / 2, winSize.height / 2 - 20) );
this->addChild(infoLabel);
this->setTouchEnabled(true);
return true;
}
示例14: sprintf
void CreatModeDisplayLayer::setResult(bool state,std::string name, double value)
{
CCLabelTTF *creatStateLabel;
if(!state)
{
creatStateLabel = CCLabelTTF::create("创造失败T T","DFGirlKelvin",60);
creatStateLabel->setPosition(ccp(320,500));
this->addChild(creatStateLabel,2);
}
else
{
creatStateLabel = CCLabelTTF::create("创造成功^ ^","DFGirlKelvin",60);
creatStateLabel->setPosition(ccp(320,500));
this->addChild(creatStateLabel,2);
char buffer[30];
sprintf(buffer, "恭喜你创造出 %s",name.c_str());
CCLabelTTF *creatResult = CCLabelTTF::create(buffer,"DFGirlKelvin",40);
creatStateLabel->setPosition(ccp(320,300));
this->addChild(creatResult,2);
sprintf(buffer, "hasCreated-%s",name.c_str());
if(!CCUserDefault::sharedUserDefault()->getBoolForKey(buffer))
{
CCUserDefault::sharedUserDefault()->setBoolForKey(buffer,true);
sprintf(buffer, "%s 加入图鉴",name.c_str());
CCLabelTTF *addLabel = CCLabelTTF::create(buffer,"DFGirlKelvin",40);
addLabel->setPosition(ccp(320,200));
this->addChild(addLabel,2);
}
int num = CCUserDefault::sharedUserDefault()->getIntegerForKey(name.c_str()) + 1;
CCUserDefault::sharedUserDefault()->setIntegerForKey(name.c_str(), num);
}
}
示例15: CC_BREAK_IF
bool TitleBarLayer::init() {
bool result = false;
do {
CC_BREAK_IF(!CCLayer::init());
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
CCSprite* titlebar = CCSprite::spriteWithSpriteFrameName("title_start");
CC_BREAK_IF(!titlebar);
titlebar->setPosition(CCPointMake(winSize.width * 0.5f, titlebar->getContentSize().height * 0.5f));
addChild(titlebar);
CCLabelTTF* descLabel = CCLabelTTF::labelWithString("",
CCSizeMake(238.0f, 50.0f),
CCTextAlignmentLeft,
"Arial",
12.0f);
descLabel->setPosition(CCPointMake(190.0f, 55.0f));
descLabel->setColor(ccWHITE);
addChild(descLabel,kZLabel,kTagDescriptLabel);
CCPoint turnPosition = CCPointMake(34.0f,40.0f);
CCLabelTTF* turnLabel = CCLabelTTF::labelWithString("", "Arial-BoldMT", 24.0f);
turnLabel->setPosition(turnPosition);
turnLabel->setColor(ccBLACK);
addChild(turnLabel,kZLabel,kTagTurnLabel);
result = true;
} while (0);
return result;
}