本文整理汇总了C++中CCLabelTTF::setScale方法的典型用法代码示例。如果您正苦于以下问题:C++ CCLabelTTF::setScale方法的具体用法?C++ CCLabelTTF::setScale怎么用?C++ CCLabelTTF::setScale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCLabelTTF
的用法示例。
在下文中一共展示了CCLabelTTF::setScale方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
// on "init" you need to initialize your instance
bool StatisticsScene::init()
{
//////////////////////////////
// 1. super init first
if ( !BaseLayer::init() )
{
return false;
}
// Set background
setBackground(1);
CCSprite* sp = CCSprite::create("texttable1.png");
sp->setPosition(ccp(0, 250 * g_fResScale));
sp->setScale(g_fResScale);
m_bgLayer->addChild(sp);
CCSize szShadow = CCSize(10 * g_fResScale, -10 * g_fResScale);
CCLabelTTF* lb = CCLabelTTF::create("OVERALL STATISTICS", "Luckiest Guy", 50);
lb->enableShadow(szShadow, 1, 1, true);
lb->setAnchorPoint(ccp(0.5, 0.5));
lb->setPosition(ccp(0, 440 * g_fResScale));
lb->setScale(g_fResScale);
m_bgLayer->addChild(lb);
for (int i = 0; i < 4; i++) {
CCLabelTTF* lb = CCLabelTTF::create(lpStatistics[i], "Luckiest Guy", 50);
lb->enableShadow(szShadow, 1, 1, true);
lb->setAnchorPoint(ccp(0, 0.5));
lb->setPosition(ccp(-560 * g_fResScale, (360 - i * 70) * g_fResScale));
lb->setScale(g_fResScale);
m_bgLayer->addChild(lb);
}
CCSprite* sp1 = CCSprite::create("texttable2.png");
sp1->setPosition(ccp(0, -250 * g_fResScale));
sp1->setScale(g_fResScale);
m_bgLayer->addChild(sp1);
CCLabelTTF* lb1 = CCLabelTTF::create("PROGRESS COMPARED TO LAST WEEK", "Luckiest Guy", 50);
lb1->enableShadow(szShadow, 1, 1, true);
lb1->setAnchorPoint(ccp(0.5, 0.5));
lb1->setPosition(ccp(0, -60 * g_fResScale));
lb1->setScale(g_fResScale);
m_bgLayer->addChild(lb1);
for (int i = 0; i < 4; i++) {
CCLabelTTF* lb = CCLabelTTF::create(lpStatistics[i], "Luckiest Guy", 50);
lb->enableShadow(szShadow, 1, 1, true);
lb->setAnchorPoint(ccp(0, 0.5));
lb->setPosition(ccp(-560 * g_fResScale, (-140 - i * 70) * g_fResScale));
lb->setScale(g_fResScale);
m_bgLayer->addChild(lb);
}
return true;
}
示例2: eraseSoldierAnim
void TapSprite::eraseSoldierAnim(int x,int y){
status->setEraseFlg(combo, x, y);
CCSprite* sprite;
sprite = status->getSprite(x,y);
CCDelayTime* delay = CCDelayTime::create(0.1875f);
CCFiniteTimeAction* func = CCCallFuncO::create( this,callfuncO_selector(TapSprite::eraseSoldierDelay),(CCObject*)sprite) ;
CCSequence* sequense = CCSequence::createWithTwoActions(delay,func);
animation++;
((CCSprite*)sprite)->runAction(sequense);
if(animation == 1){
CCScaleTo* scaleTo = CCScaleTo::create(0.1825f, 1.0f);
CCString* string = CCString::createWithFormat("%d combo",combo);
CCLabelTTF* label = CCLabelTTF::create(string->getCString(), "arial", 18.0f);
label->setScale(0.125f);
label->setPosition(sprite->getPosition());
CCNode* node = ((CCSprite*)sprite)->getParent();
if(node){
node->addChild(label);
label->runAction(scaleTo);
labelVec.push_back(label);
}
}
status->setSprite(NULL, x, y);
}
示例3: showPoint
void Point::showPoint(int player)
{
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
const char *message;
if (player == 1) {
message = "Punto para el Jugador 1";
}
else if (player == 2) {
message = "Punto para el Jugador 2";
}
CCLabelTTF *label = CCLabelTTF::create(message, "YELLOW.TTF", 30.0);
label->setColor(ccc3(64, 64, 64));
label->setScale(0.0);
label->setPosition(ccp(winSize.width/2, winSize.height*0.55));
this->addChild(label, 0);
CCDelayTime *delay = CCDelayTime::create(0.5);
CCScaleTo *scaleIn = CCScaleTo::create(0.5, 1.0);
CCScaleTo *scaleOut = CCScaleTo::create(0.5, 0.0);
//CCCallFunc *restartBall = CCCallFunc::create(this, callfunc_selector(Jugar::resetGame));
CCFiniteTimeAction* accion = CCSequence::create(scaleIn, delay, scaleOut, NULL);
label->runAction(accion);
}
示例4: createGoalLabelForPlayer
CCLabelTTF* BYGameScene::createGoalLabelForPlayer(BYGamePlayer player) {
CCPoint pos;
float rotation = 0;
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
pos.x = winSize.width / 2;
if (player == BYGamePlayer_topPlayer) {
pos.y = winSize.height * 3.0f / 4;
rotation = 180;
} else {
pos.y = winSize.height / 4;
}
CCLabelTTF* lbl = CCLabelTTF::create("",
"Marker Felt",
40);
lbl->setOpacity(0);
lbl->setScale(BYGoalLabelScaleBy);
lbl->setTag(GUI_GoalLabel);
lbl->setPosition(pos);
lbl->setRotation(rotation);
return lbl;
}
示例5: InitGridLabels
/* Initialize the grid labels. Note that we don't
* have to use a bitmap font for this. While the labels
* may move around, they don't get rewritten on a viewport change.
* We only take a hit the first time they are created.
*/
void GridLayer::InitGridLabels()
{
Viewport& viewport = Viewport::Instance();
CCSize worldSize = viewport.GetWorldSizeMeters();
float32 dx = (worldSize.width)/_subdivisions;
float32 dy = (worldSize.height)/_subdivisions;
uint32 tag = TAG_LABEL_GRID_BASE;
float32 scale = viewport.GetScale();
for(int idx = 0; idx <= _subdivisions; idx++)
{
for(int idy = 0; idy <= _subdivisions; idy++)
{
tag++;
Vec2 pt(dx*idx-worldSize.width/2,dy*idy-worldSize.height/2);
CCPoint pixel = viewport.Convert(pt);
char buffer[32];
sprintf(buffer,"(%3.1f,%3.2f)",pt.x,pt.y);
CCLabelTTF* label = CCLabelTTF::create(buffer, "Tahoma", 32);
label->setTag(tag);
label->setPosition(pixel);
label->setAnchorPoint(ccp(0.5,0.5));
label->setColor(ccc3(220, 220, 220));
label->setScale(GRID_SCALE_FACTOR/scale);
addChild(label);
}
}
}
示例6: DisplayText
void ScoresLayer::DisplayText(char *text, cocos2d::ccColor3B color, cocos2d::CCPoint ccp, int size)
{
CCLabelTTF* pLabel = CCLabelTTF::create(text, "Arial", size * 2);
pLabel->setColor(color);
pLabel->setScale(0.5);
pLabel->setPosition(ccp(ccp.x + pLabel->getContentSize().width * pLabel->getScaleX() / 2, ccp.y));
int tag = ccp.x + ccp.y * 10000;
this->removeChildByTag(tag);
this->addChild(pLabel, 10, tag);
}
示例7: createCollectionItem
AnimatedMenuItem* SelectCollection::createCollectionItem(
const JoinyCollection* collection, const SpritesLoader& spl)
{
std::string collection_name = collection->getCollectionName();
ccColor3B label_color = collection->getCollectionColor();
static ccColor3B closeLevel = GameInfo::getInstance()->getCloseColor();
ccColor3B working = closeLevel;
if(collection->isOpenCollection())
{
working = label_color;
}
else if (isFreeOpenFullGame() || GameInfo::getVersion() == Version::Premium)
{
RW::getLevelManager().makeFullGameVersion();
working = label_color;
}
CCSprite* background = spl->loadSprite("collection_button.png");
background->setColor(working);
AnimatedMenuItem* item = AnimatedMenuItem::create(
background,
this,
menu_selector(SelectCollection::onCollectionSelect));
unsigned int l_num = collection->getLevelsNumber();
std::string l_num_str = AD_to_string(l_num);
unsigned int l_curr = collection->getCompletedLevelsNumber();
std::string l_curr_str = AD_to_string(l_curr);
std::string label_text = collection_name + " "+ l_curr_str + '/' + l_num_str ;
CCLabelTTF* label = CCLabelTTF::create(label_text.c_str(),
Fonts::getFontName(),
75);
label->setTag(123);
item->addChild(label);
_item_size = background->getContentSize();
float scale = MIN(1, background->getContentSize().width * 0.7 / label->getContentSize().width);
_scale = scale;
label->setPosition(ccp(background->getContentSize().width*0.5,
background->getContentSize().height*0.5));
label->setAnchorPoint(ccp(0.5, 0.5));
label->setScale(scale);
label->setColor(working);
return item;
}
示例8: 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;
}
示例9: ccp
CCMenuItemImage * GafFeatures::addBtn(const char * text, float px, float py, SEL_MenuHandler handler, float k)
{
CCSize size = CCDirector::sharedDirector()->getWinSize();
CCMenuItemImage *res = CCMenuItemImage::create(
"CloseNormal.png",
"CloseSelected.png",
this,
handler );
res->setPosition( ccp(size.width * px, size.height * py) );
res->setScale(k);
CCLabelTTF* pLabel = CCLabelTTF::create(text, "Thonburi", 34);
pLabel->setColor(ccc3(0, 0, 255));
pLabel->setAnchorPoint(CCPoint(1, 0.5));
pLabel->setScale(k);
pLabel->setPosition( ccp(res->getPositionX() - res->getContentSize().width * k * 0.5, res->getPositionY()) );
addChild(pLabel, 100000);
return res;
}
示例10: _initComponent
void LoginLayer::_initComponent() {
CCSize size = CCDirector::sharedDirector()->getVisibleSize();
/* 大游戏之名字 */
CCSprite* nameOfGame = CCSprite::create("GAME_NAME.png");
nameOfGame->setPosition(ccp(size.width / 2, size.height - 120));
addChild(nameOfGame, 10);
/* 可移动背景 */
srand( (unsigned)time( NULL ) );
int x = rand() % 2;
int y = rand() % 1500;
CCSprite* pLoginBg = CCSprite::create("bg_big.png");
pLoginBg->setAnchorPoint(CCPointZero);
pLoginBg->setPosition(ccp(-y/*(LOGIN_BG_WIDTH - size.width) / 2*/, 0));
this->addChild(pLoginBg);
if (x == 0) {
CCActionInterval * move = CCMoveTo::create(LOGIN_BG_TIME, ccp(size.width - LOGIN_BG_WIDTH, 0));
CCActionInterval * move1 = CCMoveTo::create(LOGIN_BG_TIME, ccp(0, 0));
CCFiniteTimeAction * seq= CCSequence::create(move, move1, NULL);
CCActionInterval * repeatForever =CCRepeatForever::create((CCActionInterval* )seq);
pLoginBg->runAction(repeatForever);
} else if (x == 1) {
CCActionInterval * move = CCMoveTo::create(LOGIN_BG_TIME, ccp(0, 0));
CCActionInterval * move1 = CCMoveTo::create(LOGIN_BG_TIME, ccp(size.width - LOGIN_BG_WIDTH, 0));
CCFiniteTimeAction * seq= CCSequence::create(move, move1, NULL);
CCActionInterval * repeatForever =CCRepeatForever::create((CCActionInterval* )seq);
pLoginBg->runAction(repeatForever);
}
/* 效果火焰 */
CCParticleSystemQuad* particle = CCParticleSystemQuad::create("dzt3.plist");
particle->setAnchorPoint(CCPointZero);
particle->setPosition(ccp(320, 0));
particle->setScaleX(0.9);
particle->setAutoRemoveOnFinish(true);
addChild(particle, 11);
/* 火星 */
CCParticleSystemQuad* particlefire = CCParticleSystemQuad::create("firefly.plist");
particlefire->setAnchorPoint(CCPointZero);
particlefire->setPosition(ccp(0, 800));
particlefire->setAutoRemoveOnFinish(true);
addChild(particlefire, 11);
/* 火星1 */
CCParticleSystemQuad* particlefire1 = CCParticleSystemQuad::create("firefly2.plist");
particlefire1->setAnchorPoint(CCPointZero);
particlefire1->setPosition(ccp(0, 800));
particlefire1->setAutoRemoveOnFinish(true);
addChild(particlefire1, 11);
/* 开始游戏按钮 */
CCMenuItemImage *pLoginBtn = CCMenuItemImage::create( "pre.png",
"def.png",
this,
menu_selector(LoginLayer::gameInit));
pLoginBtn->setAnchorPoint(ccp(0.5, 0));
pLoginBtn->setPosition(ccp(size.width / 2, 70));
CCMenu* pLoginMenu = CCMenu::create(pLoginBtn, NULL);
pLoginMenu->setAnchorPoint(CCPointZero);
pLoginMenu->setPosition(CCPointZero);
this->addChild(pLoginMenu);
CCSprite* startFont = CCSprite::create("start.png");
startFont->setAnchorPoint(ccp(0.5, 0));
startFont->setPosition(ccp(size.width / 2, 115));
this->addChild(startFont);
CCActionInterval * scale = CCScaleTo::create(1, 1.2);
CCActionInterval * scale1 = CCScaleTo::create(1.5, 1);
CCFiniteTimeAction * seq= CCSequence::create(scale,scale1,NULL);
CCActionInterval * repeatForever =CCRepeatForever::create((CCActionInterval* )seq);
startFont->runAction(repeatForever);
/* 服务器列表滚动视图 */
/*
m_scrollView = CCScrollView::create(VIEW_SIZE);
m_scrollView->setViewSize(VIEW_SIZE);
m_scrollView->setContentSize(CCSizeMake(62*5, VIEW_SIZE.height));
m_scrollView->setAnchorPoint(ccp(0, 0));
m_scrollView->setPosition(SCROLLVIEW_OFFSETX, OFFSET_1136 + SCROLLVIEW_OFFSETY);
m_scrollView->setDirection(kCCScrollViewDirectionHorizontal);
m_scrollView->setBounceable(true);
m_scrollView->setDelegate(this);
this->addChild(m_scrollView);
*/
for (int i = 0; i < 5; ++i) {
CCMenuItemImage *pSvrBtn = CCMenuItemImage::create( "LG_nor.png",
"LG_nor.png",
this,
menu_selector(LoginLayer::option));
pSvrBtn->setTag(SVRBG_NORMAL + i);
pSvrBtn->setAnchorPoint(ccp(0, 0));
pSvrBtn->setPosition(ccp(SCROLLVIEW_OFFSETX + 60 * i, m_pGameState->getBottomOffset() + SCROLLVIEW_OFFSETY));
CCMenu* pMenu = CCMenu::create(pSvrBtn, NULL);
pMenu->setAnchorPoint(ccp(0, 0));
pMenu->setPosition(ccp(0, 0));
this->addChild(pMenu);
//.........这里部分代码省略.........
示例11: option
void LoginLayer::option(CCObject* pSender) {
for (int i = 0; i < 5; ++i) {
CCSprite* spBtnBg = (CCSprite*)this->getChildByTag(SVRBG_SELECT + i);
spBtnBg->setVisible(false);
CCLabelTTF* svrName = (CCLabelTTF*)this->getChildByTag(SVR_NAME + i);
svrName->setColor(ccc3(227, 168, 105));
svrName->setScale(1);
}
CCMenuItemImage* pItemImage = (CCMenuItemImage*)pSender;
switch (pItemImage->getTag() - SVRBG_NORMAL) {
case 0:
{
NetConnection* pNetConnection = NetConnection::getInstance();
pNetConnection->setUUU(HTTP_SERVER_URL);
CCUserDefault::sharedUserDefault()->setIntegerForKey(LOGIN_SERVER_KEY, 0);
CCUserDefault::sharedUserDefault()->flush();
m_pGameState->setServerId(0);
CCSprite* spBtnBg = (CCSprite*)this->getChildByTag(SVRBG_SELECT);
spBtnBg->setVisible(true);
CCLabelTTF* svrName = (CCLabelTTF*)this->getChildByTag(SVR_NAME);
svrName->setColor(ccc3(255, 215, 0));
svrName->setScale(1.1);
}
break;
case 1:
{
NetConnection* pNetConnection = NetConnection::getInstance();
pNetConnection->setUUU(HTTP_SERVER_URL1);
CCUserDefault::sharedUserDefault()->setIntegerForKey(LOGIN_SERVER_KEY, 1);
CCUserDefault::sharedUserDefault()->flush();
m_pGameState->setServerId(1);
CCSprite* spBtnBg = (CCSprite*)this->getChildByTag(SVRBG_SELECT + 1);
spBtnBg->setVisible(true);
CCLabelTTF* svrName = (CCLabelTTF*)this->getChildByTag(SVR_NAME + 1);
svrName->setColor(ccc3(255, 215, 0));
svrName->setScale(1.1);
}
break;
case 2:
{
CCSprite* spBtnBg = (CCSprite*)this->getChildByTag(SVRBG_SELECT+2);
spBtnBg->setVisible(true);
CCLabelTTF* svrName = (CCLabelTTF*)this->getChildByTag(SVR_NAME+2);
svrName->setColor(ccc3(255, 215, 0));
svrName->setScale(1.1);
}
break;
case 3:
{
CCSprite* spBtnBg = (CCSprite*)this->getChildByTag(SVRBG_SELECT+3);
spBtnBg->setVisible(true);
CCLabelTTF* svrName = (CCLabelTTF*)this->getChildByTag(SVR_NAME+2);
svrName->setColor(ccc3(255, 215, 0));
svrName->setScale(1.1);
}
break;
case 4:
{
CCSprite* spBtnBg = (CCSprite*)this->getChildByTag(SVRBG_SELECT+4);
spBtnBg->setVisible(true);
CCLabelTTF* svrName = (CCLabelTTF*)this->getChildByTag(SVR_NAME+2);
svrName->setColor(ccc3(255, 215, 0));
svrName->setScale(1.1);
}
break;
default:
CCAssert(false, "invalid server");
break;
}
}