本文整理汇总了C++中CCLabelTTF::setFontSize方法的典型用法代码示例。如果您正苦于以下问题:C++ CCLabelTTF::setFontSize方法的具体用法?C++ CCLabelTTF::setFontSize怎么用?C++ CCLabelTTF::setFontSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCLabelTTF
的用法示例。
在下文中一共展示了CCLabelTTF::setFontSize方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setTitleTTFSizeForState
void CCControlButton::setTitleTTFSizeForState(float size, CCControlState state)
{
CCLabelProtocol* label = dynamic_cast<CCLabelProtocol*>(this->getTitleLabelForState(state));
if(label)
{
CCLabelTTF* labelTTF = dynamic_cast<CCLabelTTF*>(label);
if(labelTTF != 0)
{
return labelTTF->setFontSize(size);
}
}
}
示例2: CCLabelTTF
TTFFontInit::TTFFontInit()
{
CCSize s = CCDirector::sharedDirector()->getWinSize();
CCLabelTTF* font = new CCLabelTTF();
font->init();
font->autorelease();
font->setFontName("Marker Felt");
font->setFontSize(48);
font->setString("It is working!");
this->addChild(font);
font->setPosition(ccp(s.width/2,s.height/4*2));
}
示例3: setFontSize
void CommonButton::setFontSize(float fontSize) {
CCLabelBMFont * bmFont = dynamic_cast<CCLabelBMFont * >(m_label);
CCLabelBMFont * bmFont1 = dynamic_cast<CCLabelBMFont * >(m_pBottomlabel);
if (bmFont) {
float scale = fontSize/24;
bmFont->setScale(scale);
} else {
CCLabelTTF * ttf = dynamic_cast<CCLabelTTF * >(m_label);
if (ttf) {
ttf->setFontSize(fontSize);
}
}
if (bmFont1) {
float scale = fontSize/24;
bmFont1->setScale(scale);
} else {
CCLabelTTF * ttf = dynamic_cast<CCLabelTTF * >(m_pBottomlabel);
if (ttf) {
ttf->setFontSize(fontSize);
}
}
}
示例4: initContent
void BossLottery::initContent()
{
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("ui/fightUI/bossLottery.plist");
circle = CCSprite::createWithSpriteFrameName("bossLottery_bg.png");
addChild(circle);
btn = INSTANCE(ButtonUtils)->createButton("bossLottery_btn.png", CCSizeMake(157, 207), "");
btn->setAnchorPoint(ccp(0.51, 0.37));
addChild(btn);
btn->setZoomOnTouchDown(false);
btn->addTargetWithActionForControlEvents(this, cccontrol_selector(BossLottery::btnHandler), CCControlEventTouchUpInside);
CCPoint cP = circle->getAnchorPointInPoints();
for(int i=0;i<36;i++){
BossLotteryLight *light = BossLotteryLight::create();
circle->addChild(light);
float t = i*10*3.14f/180;
light->setPosition(ccpAdd(cP,ccp(200.0f * sin(t), 200.0f * cos(t))));
array->addObject(light);
}
lightFlag = 0;
getScheduler()->scheduleSelector(schedule_selector(BossLottery::updateLight), this, 0.1f, false);
CCLabelTTF *desc = CCLabelTTF::create();
desc->setFontSize(24);
desc->setString("击杀将领");
btn->addChild(desc);
desc->setColor(ccYELLOW);
desc->setPosition(ccpAdd(btn->getAnchorPointInPoints(), ccp(0, 33)));
costLabel = CCLabelTTF::create();
costLabel->setFontSize(24);
costLabel->setColor(ccGREEN);
btn->addChild(costLabel);
costLabel->setPosition(ccpAdd(btn->getAnchorPointInPoints(), ccp(0, -34)));
costLabel->setString("首次免费");
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("common/common.plist");
closeBtn = INSTANCE(ButtonUtils)->createButton("common_redBtn_1.png", "common_redBtn_2.png", "common_redBtn_1.png", CCSizeMake(151, 48), "关闭",24,ccYELLOW);
addChild(closeBtn);
closeBtn->setPosition(ccp(0, -190));
closeBtn->addTargetWithActionForControlEvents(this, cccontrol_selector(BossLottery::close), CCControlEventTouchUpInside);
times = 1;
}
示例5: createButton
AnimatedMenuItem* SettingScene::createButton(CCSprite* logo,
SEL_MenuHandler ptr,
CCPoint& position,
const char* button_text,
const ccColor3B& color)
{
AnimatedMenuItem* button = AnimatedMenuItem::create(
logo, this, ptr);
button->addChild(logo);
button->setPosition(position);
logo->setPosition(ccp(logo->getContentSize().width/2,
logo->getContentSize().height/2));
if(button_text[0] != '\0')
{
const CCSize VISIBLE_SIZE = Screen::getVisibleSize();
CCLabelTTF * dev = CCLabelTTF::create(button_text,
Fonts::getFontName(),
60);
if(dev->getContentSize().width >= VISIBLE_SIZE.width)
dev->setFontSize(40);
dev->setPosition(ccp(logo->getContentSize().width/2,
logo->getContentSize().height/2));
dev->setColor(color);
button->addChild(dev);
}
else
{
logo->setColor(color);
}
_main_menu->addChild(button);
return button;
}
示例6: init
bool MainMenuLayer::init()
{
bool bRet = false;
do
{
if ( !CCLayer::init() )
{
break;
}
setTouchEnabled(true);
CCNotificationCenter::sharedNotificationCenter()->addObserver(this, callfuncO_selector(MainMenuLayer::onLayerClose), LAYER_QUIT, NULL);
//Background
CCSprite* bg = CCSprite::create("MainMenuBg.png");
bg->setAnchorPoint(ccp(0,0));
CCSize size = CCDirector::sharedDirector()->getWinSize();
bg->setScaleX(size.width / (bg->getContentSize().width + 100));
bg->setScaleY(size.height / (bg->getContentSize().height + 100));
bg->setPosition(ccp(0, 0));
this->addChild(bg, -1);
//Rest of items
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(mainMenuListName);
CCSpriteBatchNode *node = CCSpriteBatchNode::create(mainMenuImgName);
this->addChild(node);
CCSprite* title = CCSprite::createWithSpriteFrameName("ZSoccerTitle.png");
bg->setScaleX(size.width / bg->getContentSize().width);
bg->setScaleY(size.height / bg->getContentSize().height);
title->setPosition(ccp(size.width/2, size.height - 30 - title->boundingBox().size.height/2));
this->addChild(title, 0);
CCLabelTTF* cop = sgl_ControlFactory.createTTFLabel("copyright: Bogdan Costea 2014", ccp(size.width/2, 20));
cop->setFontSize(15);
this->addChild(cop, 0);
/***********************************
* Menu games layers
***********************************/
CCMenuItemSprite* training = sgl_SpriteFactory.createMenuItemSprite("NewGame.png", "NewGamePressed.png",menu_selector(MainMenuLayer::onNewGame), this);
CCMenuItemSprite* multi = sgl_SpriteFactory.createMenuItemSprite("Options.png", "MultiplayerPressed.png",menu_selector(MainMenuLayer::onMultiplayer), this);
_menuGame = CCMenu::create(training, multi, NULL);
_menuGame->alignItemsVertically();
_menuGame->setPosition(ccp(180,370));
// add this to the layer
this->addChild( _menuGame, 1 );
/***********************************
* Menu heleper layers
***********************************/
CCMenuItemSprite* settings = sgl_SpriteFactory.createMenuItemSprite("btnSettings.png", "btnSettingsPressed.png",menu_selector(MainMenuLayer::onSettingsChoose), this);
CCMenuItemSprite* info = sgl_SpriteFactory.createMenuItemSprite("btnInfo.png", "btnInfoPressed.png",menu_selector(MainMenuLayer::onHelp), this);
CCMenuItemSprite* help = sgl_SpriteFactory.createMenuItemSprite("btnHelp.png", "btnHelpPressed.png",menu_selector(MainMenuLayer::onHelp), this);
CCMenuItemSprite* quit = sgl_SpriteFactory.createMenuItemSprite("btnClose.png", "btnClosePressed.png",menu_selector(MainMenuLayer::onQuit), this);
_menuSet = CCMenu::create(settings, info, help, quit, NULL);
_menuSet->alignItemsHorizontally();
_menuSet->setPosition(ccp(size.width - 3 * 50 ,40));
addChild(_menuSet, 1);
std::string userName = CCUserDefault::sharedUserDefault()->getStringForKey(USER_DATA_NAME);
_lblWelcome = sgl_ControlFactory.createTTFLabel((WELCOME + userName).c_str(),
ccp(title->getPositionX() + 10, title->getPositionY() - title->boundingBox().size.height * 0.5f - 2));
_lblWelcome->setFontSize(25);
_lblWelcome->setAnchorPoint(ccp(0,1));
addChild(_lblWelcome, 0);
bRet = true;
} while (0);
return bRet;
}
示例7: handler_method_drawtext
int Bitmap::handler_method_drawtext( int ptr1,void* ptr2 )
{
Bitmap* bitmap = (Bitmap*)ptr1;
if (NULL==bitmap->p->m_emuBitmap)
return -1;
bool firstdraw = false;
CCRenderTexture* fontRender = (CCRenderTexture*)bitmap->p->m_fontRender;
if (NULL==fontRender)
{
fontRender = CCRenderTexture::create(bitmap->p->m_width,bitmap->p->m_height);
bitmap->getEmuBitmap()->addChild(fontRender);
fontRender->setPosition(ccp(bitmap->p->m_width/2,bitmap->p->m_height/2));
bitmap->p->m_fontRender = fontRender;
fontRender->retain();
firstdraw = true;
//fontRender->getSprite()->getTexture()->setAliasTexParameters();
}
DrawtextStruct* ptr2struct = (DrawtextStruct*)ptr2;
string tmpdrawchar = ptr2struct->str;
// int checknum = atoi(tmpdrawchar.c_str());
// if (checknum!=0)
// {
// char tmp[20]={0};
// sprintf(tmp,"%d",checknum);
// tmpdrawchar = tmp;
// }
CCLabelTTF* label = CCLabelTTF::create(tmpdrawchar.c_str(),ptr2struct->font->getName(),ptr2struct->font->getSize());
//label->getTexture()->setAliasTexParameters();
if (ptr2struct->font)
{
Font* f = ptr2struct->font;
label->setFontName(f->getName());
label->setFontSize(f->getSize());
label->setColor(ccc3(f->getColor()->red*f->getColor()->alpha/255,
f->getColor()->green*f->getColor()->alpha/255,
f->getColor()->blue*f->getColor()->alpha/255));
//label->setOpacity(f->getColor()->alpha);
}
label->setAnchorPoint(ccp(0,1));
label->setDimensions(CCSizeMake(ptr2struct->rect.w,ptr2struct->rect.h));
label->setPosition(ccp(ptr2struct->rect.x,rgss_y_to_cocos_y(ptr2struct->rect.y,bitmap->p->m_height)));
label->setVerticalAlignment(kCCVerticalTextAlignmentCenter);
if (ptr2struct->align == Bitmap::Center)
label->setHorizontalAlignment(kCCTextAlignmentCenter);
else if(ptr2struct->align == Bitmap::Right)
label->setHorizontalAlignment(kCCTextAlignmentRight);
else if (ptr2struct->align == Bitmap::Left)
label->setHorizontalAlignment(kCCTextAlignmentLeft);
// CCLayerColor* masklayer = CCLayerColor::create(ccc4(255,255,255,255));
// masklayer->setContentSize(label->getContentSize());
// masklayer->setPosition(ccp(ptr2struct->rect.x,rgss_y_to_cocos_y(ptr2struct->rect.y,bitmap->m_height)-masklayer->getContentSize().height));
// ccBlendFunc fun = {GL_ZERO,GL_ZERO};
// masklayer->setBlendFunc(fun);
fontRender->begin();
//masklayer->visit();
label->visit();
fontRender->end();
label->release();
delete ptr2struct;
return 0;
}
示例8: onCreate
void onCreate(CCNode *parent)
{
CCSize size = parent->getContentSize();
float x_middle = size.width / 2;
float vertical = size.height * 0.25f;
CCLabelTTF* label = CCLabelTTF::create(_("SelectColection.BuyFullVerdionPopUp.BuyTitle"),
Fonts::getFontName(),
62);
label->setFontSize(48);
label->setPosition(ccp(x_middle, size.height*0.85f));
parent->addChild(label);
//add 3 stars
SpritesLoader spl = GraphicsManager::getLoaderFor(parent,
"level-end/big_stars.plist",
"level-end/big_stars.png");
spl->inject();
CCSprite* stars_spr = spl->loadSprite("big_stars_3.png");
stars_spr->setScale(0.75f);
stars_spr->setPosition(ccp(x_middle, size.height*0.65f));
//add "or" text
CCLabelTTF* or_text = CCLabelTTF::create(_("SelectColection.BuyFullVerdionPopUp.OrText"),
Fonts::getFontName(),
40);
or_text->setPosition(ccp(x_middle, size.height*0.5f));
parent->addChild(or_text);
/**
* @brief menu_spl
*/
SpritesLoader menu_spl = GraphicsManager::getLoaderFor(0,
"collection-menu/collection_button.plist",
"collection-menu/collection_button.png");
MenuSpriteBatch* menu = MenuSpriteBatch::create(menu_spl);
menu->setPosition(ccp(0,0));
menu->setAnchorPoint(ccp(0,0));
menu->setContentSize(size);
parent->addChild(menu);
CCSprite* parent_rgb = (CCSprite*)parent->getChildByTag(123);
if(parent_rgb)
parent_rgb->setColor(GameInfo::getInstance()->getNegativeColor());
CCSprite* coll_button = menu_spl->loadSprite("collection_button.png");
//coll_button->setScale(coll_button->getContentSize().width/
// parent->getContentSize().width*0.6);
AnimatedMenuItem *buy_item = AnimatedMenuItem::create(
coll_button,
this, menu_selector(Me::onBuy));
buy_item->setPosition(ccp(size.width*0.5,
vertical));
buy_item->setBaseScale(coll_button->getContentSize().width/
parent->getContentSize().width*0.8);
std::string text = _("SelectColection.BuyFullVerdionPopUp.Yes");
std::string price = ADInApp::getProduct("unlock_full")->getPrice();
std::string button_buy_text = text +'\n' + price;
CCLabelTTF * buy_text = CCLabelTTF::create(button_buy_text.c_str(),
Fonts::getFontName(),
45);
buy_text->setColor(ccc3(255,255,255));
buy_text->setPosition(ccp(buy_item->getContentSize().width/2,
buy_item->getContentSize().height/2));
buy_item->addChild(buy_text);
menu->menu()->addChild(buy_item);
}
示例9: update
void WordTreeScene::update(float dt) {
if( isIdle==true ) {
return;
}
totalIdleTimes += dt;
if( isProcessing==true ) {
return;
}
else if( totalIdleTimes>=5.0f ) {
totalIdleTimes = 0.0f;
CCUserDefault::sharedUserDefault()->setStringForKey("FromCppToObjC", "requestWord");
}
static CCSize designResolutionSize = CCEGLView::sharedOpenGLView()->getDesignResolutionSize();
ChipmunkManager::getInstance()->update(dt);
WordModels::getInstance()->update(dt);
Word* word = WordModels::getInstance()->getNotRenderedWord();
if( word!=NULL ) {
CCLabelTTF* wordLabel = CCLabelTTF::create(word->getWord()->getCString(), "Arial", DEFAULT_FONT_SIZE);
float offsetX = CCRANDOM_MINUS1_1()*400;
float offsetY = CCRANDOM_MINUS1_1()*300+100;
wordLabel->setPosition(ccp(designResolutionSize.width/2+offsetX,designResolutionSize.height/2+offsetY));
word->setLabel(wordLabel);
word->setRendered(true);
CCSprite* sprite = CCSprite::create("images/heart.png");
sprite->setPosition(wordLabel->getPosition());
CCSize labelSize = wordLabel->getContentSize();
float spriteScale = MAX(labelSize.width, labelSize.height)/HEART_IMAGE_SIZE;
sprite->setScale(spriteScale+spriteScale*0.3f);
word->setSprite(sprite);
this->addChild(sprite);
this->addChild(wordLabel);
updatePhysics(word);
word = NULL;
return;
}
word = WordModels::getInstance()->getDirtyWord();
if( word!=NULL ) {
CCLabelTTF* wordLabel = word->getLabel();
CCSprite* sprite = word->getSprite();
if( wordLabel!=NULL && sprite!=NULL ) {
wordLabel->setFontSize(DEFAULT_FONT_SIZE+LABEL_INCREASE_SCALE_PER_WORD*word->getCount());
CCSize labelSize = wordLabel->getContentSize();
float spriteScale = MAX(labelSize.width, labelSize.height)/HEART_IMAGE_SIZE;
sprite->setScale(spriteScale+spriteScale*0.3f);
CCScaleTo* scaleUp = CCScaleTo::create(0.2f, spriteScale+spriteScale*0.5f);
CCEaseIn* in = CCEaseIn::create(scaleUp, 2.0f);
CCScaleTo* scaleDown = CCScaleTo::create(0.2f, spriteScale+spriteScale*0.3f);
CCEaseOut* out = CCEaseOut::create(scaleDown, 2.0f);
CCSequence* sequence = CCSequence::create(in, out, NULL);
sprite->runAction(sequence);
updatePhysics(word);
}
return;
}
}
示例10: showItems
void CATabBar::showItems()
{
do
{
CC_BREAK_IF(m_pViews.empty() == false);
unsigned int count = MIN(m_nMaxShowCount, m_pItems.size());
float width = m_obContentSize.width / count;
float height = m_obContentSize.height;
m_cItemSize = CCSize(width, height);
for (unsigned int i=0; i<count; i++)
{
CAView* view = CAView::createWithFrame(CCRect(i * width, 0, width, height), ccc4(0, 0, 0, 0));
this->insertSubview(view, 3);
view->setDisplayRange(false);
m_pViews.push_back(view);
CAImageView* imageView = NULL;
CCLabelTTF* title = NULL;
if (m_pItems.at(i)->getImage())
{
imageView = CAImageView::createWithImage(m_pItems.at(i)->getImage());
imageView->setTag(0xffff);
view->addSubview(imageView);
}
if (m_pItems.at(i)->getTitle().compare("") != 0)
{
int fontSize = this->getContentSize().height / 5.0f;
title = CCLabelTTF::create(m_pItems.at(i)->getTitle().c_str(), "Arial", fontSize);
title->setTag(0xfffe);
view->addSubview(title);
}
if (imageView && title == NULL)
{
CCSize imageViewSize = imageView->getBounds().size;
float scaleX = width / imageViewSize.width * 2/3.0f;
float scaleY = height / imageViewSize.height * 2/3.0f;
float scale = MIN(scaleX, scaleY);
scale = MIN(scale, 1.0f);
imageViewSize = ccpMult(imageViewSize, scale);
CCRect rect;
rect.origin = view->getBounds().size/2;
rect.size = imageViewSize;
imageView->setCenter(rect);
}
else if (title && imageView == NULL)
{
int fontSize = this->getContentSize().height / 2.0f;
title->setFontSize(fontSize);
CCSize titleSize = title->getBounds().size;
float titleScale = height / titleSize.height * 1/2.0f;
titleSize = ccpMult(titleSize, titleScale);
CCRect rect;
rect.origin = view->getBounds().size/2;
rect.size = titleSize;
title->setCenter(rect);
}
else if (title && imageView)
{
CCSize imageViewSize = imageView->getBounds().size;
float scaleX = width / imageViewSize.width * 1/2.0f;
float scaleY = height / imageViewSize.height * 1/2.0f;
float scale = MIN(scaleX, scaleY);
scale = MIN(scale, 1.0f);
imageViewSize = ccpMult(imageViewSize, scale);
CCRect rect;
rect.size = imageViewSize;
rect.origin = view->getBounds().size;
rect.origin.x *= 1/2.0f;
rect.origin.y *= 7/20.0f;
imageView->setCenter(rect);
CCSize titleSize = title->getBounds().size;
float titleScale = height / titleSize.height * 3/10;
titleSize = ccpMult(titleSize, titleScale);
CCRect rect2;
rect2.size = titleSize;
rect2.origin = view->getBounds().size;
rect2.origin.x *= 1/2.0f;
rect2.origin.y *= 15/20.0f;
title->setCenter(rect2);
}
}
//.........这里部分代码省略.........