本文整理汇总了C++中CCLabelTTF::setVerticalAlignment方法的典型用法代码示例。如果您正苦于以下问题:C++ CCLabelTTF::setVerticalAlignment方法的具体用法?C++ CCLabelTTF::setVerticalAlignment怎么用?C++ CCLabelTTF::setVerticalAlignment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCLabelTTF
的用法示例。
在下文中一共展示了CCLabelTTF::setVerticalAlignment方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
/**
* 初始化函数
* @param enterLimit 进入限制
* @param baseBet 底注
*/
void YJGameModeLabel::init(const char* enterLimit, const char* baseBet)
{
const float label_height = 30.0f ;
////////////////////////// 进入限制 ///////////////////////
char entryfeeStr[30] ;
sprintf(entryfeeStr, "进入限制:%s金币\0", enterLimit) ;
CCLabelTTF* enterLimitLabel = CCLabelTTF::create(entryfeeStr, "font01.ttf", 20.0f) ;
enterLimitLabel->setColor(ccc3(0, 0, 0)) ;
enterLimitLabel->setAnchorPoint(ccp(0, 0)) ;
enterLimitLabel->setPosition(ccp(0, label_height)) ;
enterLimitLabel->setHorizontalAlignment(kCCTextAlignmentLeft) ; // 水平对齐方式
enterLimitLabel->setVerticalAlignment(kCCVerticalTextAlignmentCenter) ; // 垂直对齐方式
this->addChild(enterLimitLabel) ;
////////////////////////// 底注 /////////////////////////
char awardStr[30] ;
sprintf(awardStr, " 底注:%s金币\0", baseBet) ;
CCLabelTTF* baseBetLabel = CCLabelTTF::create(awardStr, "font01.ttf", 20.0f) ;
baseBetLabel->setColor(ccc3(0, 0, 0)) ;
baseBetLabel->setAnchorPoint(ccp(0, 0)) ;
baseBetLabel->setPosition(ccp(0, 0)) ;
baseBetLabel->setHorizontalAlignment(kCCTextAlignmentLeft) ; // 水平对齐方式
baseBetLabel->setVerticalAlignment(kCCVerticalTextAlignmentCenter) ; // 垂直对齐方式
this->addChild(baseBetLabel) ;
float width = enterLimitLabel->getContentSize().width > baseBetLabel->getContentSize().width?enterLimitLabel->getContentSize().width:baseBetLabel->getContentSize().width ;
this->setContentSize(CCSizeMake(width, 2*label_height)) ;
}
示例2: initBtLicencia
void Ajustes::initBtLicencia(){
btLicencia = MenuItemImage::create("ajustes_btPaginaWeb.png", "ajustes_btPaginaWeb_down.png", callfunc_selector(Ajustes::irWebLicencia));
btLicencia->setScale(escalaAncha);
btLicencia->setAnchorPoint(Vec2(0,1));
btLicencia->setPosition(espacioSuperiorBtAtras*escala,visibleSize.height/4-(espacioSuperiorBtAtras*escalaAncha));
if(menuCreditos == NULL){
menuCreditos = Menu::create(btLicencia, NULL);
menuCreditos->setPosition(Vec2::ZERO);
botonAtras->setZOrder(10);
this->addChild(menuCreditos, 1);
}else{
menuCreditos->addChild(btLicencia);
}
//btCreditosTexto
CCLabelTTF *lbBtLicencia = CCLabelTTF::create(LanguageManager::getInstance()->getString("AjustesBtLicencia"), "HVD_Comic_Serif_Pro.ttf", 70,Size(btLicencia->getContentSize().width, 120), TextHAlignment::CENTER);
lbBtLicencia->setColor(Color3B(255,255,255));
lbBtLicencia->setVerticalAlignment(TextVAlignment::CENTER);
lbBtLicencia->setAnchorPoint(Vec2(0,0));
lbBtLicencia->setPosition(0,0);
btLicencia->addChild(lbBtLicencia);
}
示例3: init
/**
* 初始化方法,继承CCLayer的方法
*/
bool WelcomeView::init()
{
if(!CCLayer::init())
{
return false ;
}
CCSize winSize = CCDirector::sharedDirector()->getWinSize() ;
// 背景
CCSprite* downBg = CCSprite::create("bg_welcome.png") ;
downBg->setAnchorPoint(ccp(0.5, 0)) ;
downBg->setPosition(ccp(winSize.width/2, 0)) ;
this->addChild(downBg, 0) ;
// 加载logo
CCSprite* logo = CCSprite::create("logo_01.png") ;
logo->setAnchorPoint(ccp(0.5, 0.5)) ;
logo->setPosition(ccp(winSize.width/2, winSize.height/2)) ;
this->addChild(logo, 1) ;
//////////////////////////// LOADING //////////////////////////////////////////
CCLabelTTF* loadingLabel = CCLabelTTF::create("LOADING...", "Arial", 26) ;
loadingLabel->setAnchorPoint(ccp(0.5, 0)) ;
loadingLabel->setPosition(ccp(winSize.width/2, 65)) ;
loadingLabel->setHorizontalAlignment(kCCTextAlignmentCenter) ; // 水平对齐方式
loadingLabel->setVerticalAlignment(kCCVerticalTextAlignmentCenter) ; // 垂直对齐方式
this->addChild(loadingLabel, 1) ;
///////////////////////////////// 进度条 //////////////////////////////////////////
const float margin_bottom = 38.0f ;
// 进度条背景
CCSprite* progressBarBg = CCSprite::create("bg_loading.png") ;
progressBarBg->setAnchorPoint(ccp(0.5, 0)) ;
progressBarBg->setPosition(ccp(winSize.width/2, margin_bottom));
this->addChild(progressBarBg, 1) ;
// 进度条
progressBar = CCProgressTimer::create(CCSprite::create("bg_loading_icon.png"));
progressBar->setType( kCCProgressTimerTypeBar ); //设置进度条为水平
// Setup for a bar starting from the left since the midpoint is 0 for the x
progressBar->setMidpoint(ccp(0,0));
// Setup for a horizontal bar since the bar change rate is 0 for y meaning no vertical change
progressBar->setBarChangeRate(ccp(1, 0)); // 设置进度条的长度和高度开始变化的大小
progressBar->setAnchorPoint(ccp(0.5, 0)) ;
progressBar->setPosition(ccp(winSize.width/2, margin_bottom+2));
this->addChild(progressBar, 1) ;
return true ;
}
示例4: presentExitButton
void HUD::presentExitButton() {
if (!exitButton) {
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
CCLabelTTF* exitButtonLabel = CCLabelTTF::create("End Game", "Arial", normalFontSize);
exitButtonLabel->setHorizontalAlignment(kCCTextAlignmentCenter);
exitButtonLabel->setVerticalAlignment(kCCVerticalTextAlignmentCenter);
exitButton = CCMenuItemLabel::create(exitButtonLabel, this, menu_selector(HUD::exitButtonCallback));
auto labelSize = exitButton->getContentSize();
exitButton->setPosition(ccp(origin.x + visibleSize.width / 2, origin.y + visibleSize.height * 0.3f));
exitButton->retain();
}
menu->addChild(exitButton);
}
示例5: initContent
void BossLotteryNotice::initContent()
{
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("ui/fightUI/gainGold.plist");
CCSprite *bg = CCSprite::createWithSpriteFrameName("gainGold_bg.png");
addChild(bg);
CCSprite *title = CCSprite::createWithSpriteFrameName("gainGold_title.png");
bg->addChild(title);
title->setPosition(ccp(bg->getContentSize().width/2, bg->getContentSize().height - 30));
CCLabelTTF *content = CCLabelTTF::create();
content->setFontSize(24);
content->setColor(ccGREEN);
bg->addChild(content);
content->setPosition(ccp(bg->getContentSize().width/2, bg->getContentSize().height/2 + 30));
content->setDimensions(CCSizeMake(bg->getContentSize().width - 40, 200));
content->setVerticalAlignment(kCCVerticalTextAlignmentCenter);
content->setHorizontalAlignment(kCCTextAlignmentCenter);
content->setString(CCString::createWithFormat("恭喜获得击杀将领%d倍奖励",multiple)->getCString());
}
示例6: buildScene
void HelpScene::buildScene()
{
// Call super build scene.
BaseScene::buildScene();
BaseScene::addTipBoard("Do you know that EziByte team provides you personalize support for all your queries? Just try sending email to them at [email protected]");
buildHeader(2, "Help", "Get all the help you need.");
const char* helpText = "What is EziSocial?\n\nEziSocial is a powerful social networking plugin designed for Cocos2D-X platform to meet the social networking capabilities required in a game. The tool is written in Java, Objective-C and C++. EziSocial plugin uses common development code for both Android and iOS Cocos2D-x project. So, there is no duplicity of code and you need not to worry about portability issue at all.\n\nFor more details you can visit our website. http:://www.ezibyte.com";
CCLabelTTF* helpTextLabel = CCLabelTTF::create("", "Arial", SCALED_VALUE(20.0f));
helpTextLabel->setDimensions(CCSizeMake(AppDelegate::SCREEN_WIDTH * 0.60, AppDelegate::SCREEN_HEIGHT * 0.72));
helpTextLabel->setString(helpText);
this->addChild(helpTextLabel);
helpTextLabel->setAnchorPoint(ccp(0.0, 1.0));
helpTextLabel->setVerticalAlignment(kCCVerticalTextAlignmentTop);
float py = 1 - (1 - 0.764);
PlaceNode(helpTextLabel, 0.38, py);
}
示例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: makeTargets
void TargetLayer::makeTargets(int countTargets, cocos2d::CCArray *targetLetters)
{
this->removeAllChildrenWithCleanup(true);
targets->removeAllObjects();
int targetCount = 0;
int rows =(countTargets + DEFAULT_COLS - 1) / DEFAULT_COLS;
int cols = countTargets > DEFAULT_COLS?DEFAULT_COLS:countTargets;
float targetSpaceX = (winSize.width - (2.0 * TARGET_AREA_PAD)) / cols;
for (int rowIndex = 0; rowIndex < rows; rowIndex++) {
// Check if more targets than letters. Just stop making targets.
if (targetCount >= targetLetters->count() && targetLetters->count() != 0) {
break;
}
cols = (countTargets - targetCount) > DEFAULT_COLS?DEFAULT_COLS:(countTargets - targetCount);
targetSpaceX = (winSize.width - (2.0 * TARGET_AREA_PAD)) / cols;
CCLog("Cols is %d", cols);
CCLog("targetSpaceX is %f", targetSpaceX);
// Calculate the Y position
float yPos = winSize.height - TARGET_AREA_Y_OFFSET - 120 * SCALEY * rowIndex;
for (int colIndex = 0; colIndex < cols ; colIndex++) {
// Calculate the X position
float xPos = (colIndex * targetSpaceX) + targetSpaceX * 0.5 + TARGET_AREA_PAD;
// Add Targret Sprite
CCSprite* targetSprite = CCSprite::create(getResPath(GAME_TARGET_IMG));
targetSprite->setPosition(ccp(xPos, yPos));
targetSprite->setScale(SCALE * 1.2);
this->addChild(targetSprite, 0);
// Add the target sprite
targets->addObject(targetSprite);
string fontName;
bool fontType = GameOptions::getInstance()->getFontType();
if (fontType) {
fontName = FONT_LETTER_NOR;
}else
{
fontName = FONT_LETTER_CUR;
}
CCLabelTTF* letterSprite;
if (targetLetters->count() > 0) {
// Get the next letter for the target
CCInteger* numberObj = (CCInteger*)targetLetters->objectAtIndex(targetCount);
int letterIndex = numberObj->getValue();
targetSprite->setTag(TAG_TARGET + letterIndex);
// Make the letter sprite(Label) on the target. Font size is the target width
string letterString = AlphaBetUtils::getInstance()->getKeyMapFont(letterIndex);
letterSprite = CCLabelTTF::create(letterString.c_str(), fontName.c_str(), targetSprite->getContentSize().width * 0.6);
letterSprite->setVerticalAlignment(kCCVerticalTextAlignmentCenter);
letterSprite->setHorizontalAlignment(kCCTextAlignmentCenter);
letterSprite->setDimensions(CCSize(targetSprite->getContentSize().width, targetSprite->getContentSize().width));
}else
{
// Fill-in an Empty Target
letterSprite = CCLabelTTF::create("", fontName.c_str(), targetSprite->getContentSize().width);
}
letterSprite->setColor(letterColor);
CCPoint centerPoint = ccp(targetSprite->getContentSize().width * 0.5, targetSprite->getContentSize().height * 0.5);
letterSprite->setPosition(centerPoint);
targetSprite->addChild(letterSprite, 10, TAG_LETTER);
targetCount++;
}
}
CCLOG("Targets Count is %d", targets->count());
}
示例9: initTopBar
// 初始化顶部bar
void ActivityView::initTopBar(CCSize winSize)
{
////////////////////////////////////////////////////////////////////////////////////////////////////
// topBarNode 背景
CCSprite* topBarBg = CCSprite::create("bg_nav_top.png") ;
topBarBg->setAnchorPoint(ccp(0.5, 0)) ;
topBarBg->setPosition(ccp(winSize.width/2, 0)) ;
const float topBar_height = topBarBg->getContentSize().height ;
// 顶部条信息 //////////////////////////////////////////////////////////////////////////////////////
this->topBarNode = CCNode::create() ;
this->topBarNode->setContentSize(CCSizeMake(winSize.width, topBar_height)) ;
this->topBarNode->setAnchorPoint(ccp(0, 0)) ;
this->topBarNode->setPosition(ccp(0, winSize.height - topBar_height)) ;
this->addChild(this->topBarNode, 0, 1) ;
// 将topBarNode背景加入到topBarNode
this->topBarNode->addChild(topBarBg, 0 ) ;
///////////////////////////// 左侧布局 //////////////////////////
CCNode* leftNode = CCNode::create() ;
leftNode->setContentSize(CCSizeMake(300, topBar_height)) ;
leftNode->setAnchorPoint(ccp(0, 0.5)) ;
leftNode->setPosition(ccp(30, topBar_height/2)) ;
this->topBarNode->addChild(leftNode, 1) ;
// 头像
CCSprite* headPortraitSprite = CCSprite::create("user/head_default_f2.png") ;
headPortraitSprite->setAnchorPoint(ccp(0, 0)) ;
headPortraitSprite->setPosition(ccp(0, 10)) ;
headPortraitSprite->setScale(0.8) ;
leftNode->addChild(headPortraitSprite) ;
// 昵称
CCLabelTTF* nikeNameLabel = CCLabelTTF::create("昵称:我是主角", "font01.ttf", 22.0f) ;
// nikeNameLabel->setColor(ccc3(191, 173, 111)) ;
nikeNameLabel->setAnchorPoint(ccp(0, 0)) ;
nikeNameLabel->setPosition(ccp(70, topBar_height/2+2)) ;
nikeNameLabel->setHorizontalAlignment(kCCTextAlignmentLeft) ; // 水平对齐方式
nikeNameLabel->setVerticalAlignment(kCCVerticalTextAlignmentCenter) ; // 垂直对齐方式
leftNode->addChild(nikeNameLabel) ;
// 金币
CCLabelTTF* goldCoinLabel = CCLabelTTF::create("金币:10000", "font01.ttf", 22.0f) ;
goldCoinLabel->setAnchorPoint(ccp(0, 1)) ;
goldCoinLabel->setPosition(ccp(70, topBar_height/2)) ;
goldCoinLabel->setHorizontalAlignment(kCCTextAlignmentLeft) ; // 水平对齐方式
goldCoinLabel->setVerticalAlignment(kCCVerticalTextAlignmentCenter) ; // 垂直对齐方式
leftNode->addChild(goldCoinLabel) ;
// 信息
CCSprite* titleMsg = CCSprite::create("icon_title_activity.png") ;
titleMsg->setAnchorPoint(ccp(0.5, 0.5)) ;
titleMsg->setPosition(ccp(winSize.width/2, topBar_height/2)) ;
this->topBarNode->addChild(titleMsg, 1) ;
// 分割线
CCSprite* spliteLineLeft = CCSprite::create("icon_top_nav_splite.png") ;
spliteLineLeft->setAnchorPoint(ccp(0, 1)) ;
spliteLineLeft->setPosition(ccp(winSize.width/3+10, topBar_height)) ;
this->topBarNode->addChild(spliteLineLeft, 1) ;
// 分割线
CCSprite* spliteLineRight = CCSprite::create("icon_top_nav_splite.png") ;
spliteLineRight->setAnchorPoint(ccp(0, 1)) ;
spliteLineRight->setPosition(ccp(winSize.width*2/3-20, topBar_height)) ;
this->topBarNode->addChild(spliteLineRight, 1) ;
/////////////////////////////////////////////////////////////////////////////////////////////////
/****************************** 菜单选项 ********************************************************/
// 右侧menu
const float right_width = 200 ;
const float item_width = 55 ;
// 礼物
CCMenuItemImage* menuGifts = CCMenuItemImage::create("menu_gifts_n.png", "menu_gifts_s.png", this,
menu_selector(ActivityView::menuGiftsClickCallback)) ;
// menuBack->setContentSize(CCSizeMake(67, 68)) ;
menuGifts->setAnchorPoint(ccp(0, 0.5)) ;
menuGifts->setPosition(ccp(0, topBar_height/2)) ;
//menuGifts->setPosition(ccp(right_width-2*item_width, topBar_height/2)) ;
//rightMenu->addChild(menuGifts) ;
// 返回大厅
CCMenuItemImage* menuBack = CCMenuItemImage::create("menu_back_n.png", "menu_back_s.png", this,
menu_selector(MessageView::menuBackClickCallback)) ;
menuBack->setAnchorPoint(ccp(0, 0.5)) ;
menuBack->setPosition(ccp(2*(item_width+10), topBar_height/2)) ;
//menuBack->setPosition(ccp(right_width, topBar_height/2)) ;
//rightMenu->addChild(menuBack) ;
//.........这里部分代码省略.........
示例10: JuegoTerminado
void Akuerdate::JuegoTerminado(){
CocosDenshion::SimpleAudioEngine::getInstance()->playEffect("ganar.mp3");
escuchadores = false;
juegoTerminado = true;
LayerColor *lyConseguido = LayerColor::create(Color4B(124,180,224,200));
lyConseguido->setPosition(cuadroJuego->getPosition());
lyConseguido->setContentSize(cuadroJuego->getContentSize());
lyConseguido->setLocalZOrder(20);
addChild(lyConseguido);
Sprite *foco = Sprite::create("preguntator_focoLuz.png");
foco->setScaleX(escalaAlta);
foco->setScaleY(0);
foco->setScaleZ(escalaAlta);
foco->setAnchorPoint(Vec2(0.5,1));
foco->setPosition(lyConseguido->getContentSize().width/2,lyConseguido->getContentSize().height);
lyConseguido->addChild(foco);
//animacion foco
ScaleTo *aniFoco = ScaleTo::create(0.7, escalaAlta);
foco->runAction(aniFoco);
__String *txtConsegido = __String::createWithFormat("%s %s",LanguageManager::getInstance()->getString("JUEGO_TX_FINAL_EXITO_2").c_str(),sNombreProfesion->getCString());
CCLabelTTF *txConseguido = CCLabelTTF::create(txtConsegido->getCString(), "HVD_Comic_Serif_Pro.ttf",120*escala,Size((visibleSize.width),(220*escala)*2), TextHAlignment::CENTER);
txConseguido->setColor(Color3B(25,78,121));
txConseguido->setVerticalAlignment(TextVAlignment::CENTER);
txConseguido->setAnchorPoint(Vec2(0.5,1));
txConseguido->setPosition(lyConseguido->getContentSize().width/2,visibleSize.height+(280*escala));
lyConseguido->addChild(txConseguido);
//animacion textoConsegido
MoveTo *aniTxConseguido = MoveTo::create(0.3, Vec2(lyConseguido->getContentSize().width/2,(lyConseguido->getContentSize().height)));
txConseguido->runAction(aniTxConseguido);
Sprite *pizzarra = Sprite::create("pizzarra_final_tiempo.png");
pizzarra->setScale(escalaAlta);
pizzarra->setAnchorPoint(Vec2(0.5,1));
pizzarra->setPosition(visibleSize.width,(lyConseguido->getContentSize().height)-(txConseguido->getContentSize().height));
lyConseguido->addChild(pizzarra);
CCLabelTTF *nAciertosPizarra = CCLabelTTF::create(reloj->getString(), "HVD_Comic_Serif_Pro.ttf",200,pizzarra->getContentSize(), TextHAlignment::CENTER);
nAciertosPizarra->setColor(Color3B(255,255,255));
nAciertosPizarra->setVerticalAlignment(TextVAlignment::CENTER);
nAciertosPizarra->setAnchorPoint(Vec2(0,0));
nAciertosPizarra->setPosition(0,0);
pizzarra->addChild(nAciertosPizarra);
//animacion pizzara
MoveTo *aniPizzarra = MoveTo::create(0.3, Vec2(lyConseguido->getContentSize().width/2,pizzarra->getPositionY()));
pizzarra->runAction(aniPizzarra);
CGestorRecursos *gRecursos = new CGestorRecursos();
CRecurso *recursoAleatorio = gRecursos->obtenerRecursoBloqueadoAleatorio();
if(recursoAleatorio!=NULL){
gRecursos->quitarRecursoBloqueado(recursoAleatorio);
Sprite *txPremio = Sprite::create("preguntator_finjuego_texto_inferior.png");
txPremio->setScale(escalaAlta);
txPremio->setAnchorPoint(Vec2(0.5,0));
txPremio->setPosition(foco->getPositionX(),foco->getPositionY()-(foco->getContentSize().height*escalaAlta));
txPremio->setOpacity(0);
lyConseguido->addChild(txPremio);
//animacion txPremio
Sequence *aniPremio1 = Sequence::create(DelayTime::create(0.7),FadeIn::create(1),NULL);
txPremio->runAction(aniPremio1);
Sprite *premio = Sprite::create(recursoAleatorio->uri->getCString());
float escalaPremio = ((pizzarra->getContentSize().height*pizzarra->getScale())/2)/premio->getContentSize().height;
float escalaPremioAncha = ((pizzarra->getContentSize().width*pizzarra->getScale()))/premio->getContentSize().width;
if(escalaPremioAncha<escalaPremio)
escalaPremio = escalaPremioAncha;
premio->setScale(escalaPremio);
premio->setAnchorPoint(Vec2(0.5,0));
premio->setPosition(txPremio->getPositionX(),txPremio->getPositionY()+(20*escalaPremio)+(txPremio->getContentSize().height*txPremio->getScaleY()));
premio->setOpacity(0);
//nuevo
if(recursoAleatorio->tipoRecurso->getValue()!=Configuracion::rcsTipoOjos&&recursoAleatorio->tipoRecurso->getValue()!=Configuracion::rcsTipoAccesorio&&recursoAleatorio->tipoRecurso->getValue()!=Configuracion::rcsTipoDientes&&recursoAleatorio->tipoRecurso->getValue()!=Configuracion::rcsTipoColor)
premio->runAction(TintTo::create(0,0,0,0));
lyConseguido->addChild(premio);
string textoTraducido1 = LanguageManager::getInstance()->getString("kitDe");
string keyTexto2 = __String::createWithFormat("tipoRecurso%i",recursoAleatorio->tipoRecurso->getValue())->getCString();
string textoTraducido2 = LanguageManager::getInstance()->getString(keyTexto2);
string textoFinal = __String::createWithFormat("%s %s",textoTraducido1.c_str(),textoTraducido2.c_str())->getCString();
CCLabelTTF *nAciertosPizarra = CCLabelTTF::create(textoFinal, "HVD_Comic_Serif_Pro.ttf",60,Size(lyConseguido->getContentSize().width,txPremio->getContentSize().height), TextHAlignment::CENTER);
nAciertosPizarra->setColor(Color3B(229,57,57));
nAciertosPizarra->setVerticalAlignment(TextVAlignment::BOTTOM);
nAciertosPizarra->setAnchorPoint(Vec2(0.5,0));
nAciertosPizarra->setPosition(txPremio->getContentSize().width/2,80);
nAciertosPizarra->setOpacity(0);
txPremio->addChild(nAciertosPizarra);
//.........这里部分代码省略.........
示例11:
//.........这里部分代码省略.........
//桌子编号
if (m_pResManager->GenerateNodeByCfgID(eSpriteType_Base, Star97_Room_Table_Num_Font, tableSprite.m_pTableNum))
{
szBKSize = tableSprite.m_pTableBK->getContentSize();
tableSprite.m_pTableNum->setAnchorPoint(ccp(0.5, 0.5));
tableSprite.m_pTableNum->setPosition(ccp(120.f,240.f));
//tableSprite.m_pTableNum->setScale(0.3f);
if (NULL != tableSprite.m_pTableBK)
{
tableSprite.m_pTableBK->addChild(tableSprite.m_pTableNum);
}
}
//游戏桌子编号
if (m_pResManager->GenerateNodeByCfgID(eSpriteType_Base, Star97_Room_Table_Num_Font, tableSprite.m_pTableNumP))
{
tableSprite.m_pTableNumP->setAnchorPoint(ccp(0.5, 0.5));
tableSprite.m_pTableNumP->setPosition(ccp(120.f,240.f));
//tableSprite.m_pTableNumP->setScale(0.3f);
if (NULL != tableSprite.m_pTableP)
{
tableSprite.m_pTableP->addChild(tableSprite.m_pTableNumP);
}
}
//座位
for (int n = 0; n < 1; n++)
{
CSeatSprite seat;
CCLabelTTF *titleButton = CCLabelTTF::create("", "Arial", 30);
if (NULL == titleButton)
{
ERROR_CHECK;
break;
}
titleButton->setColor(ccc3(159, 168, 176));
CCScale9Sprite *backgroundButton = NULL;
if (!m_pResManager->GenerateNodeByCfgID(eSpriteType_Cfg, Star97_Room_Sit, backgroundButton))
{
ERROR_CHECK;
break;
}
CCControlButton* pButton = CMoveableButton::create(titleButton, backgroundButton);
if (NULL == pButton)
{
ERROR_CHECK;
break;
}
CCScale9Sprite *backgroundHighlightedButton = NULL;
if (m_pResManager->GenerateNodeByCfgID(eSpriteType_Cfg, Star97_Room_Sit, backgroundHighlightedButton))
{
pButton->setBackgroundSpriteForState(backgroundHighlightedButton, CCControlStateHighlighted);
}
CCScale9Sprite *backgroundDisibleButton = NULL;
if (m_pResManager->GenerateNodeByCfgID(eSpriteType_Cfg, Star97_Room_Sit_D, backgroundDisibleButton))
{
pButton->setBackgroundSpriteForState(backgroundDisibleButton, CCControlStateDisabled);
}
pButton->setPosition(CCPoint(134.0f,105.0f));
pButton->setAdjustBackgroundImage(false);
//pButton->setZoomOnTouchDown(false);
pButton->setTag(n);
if (tableSprite.m_pTableP)
{
pButton->setZOrder(tableSprite.m_pTableP->getZOrder()+4);
}
tableSprite.m_pTableBK->addChild(pButton);
seat.m_pSeat = pButton;
//更新名称
CCLabelTTF* pUserName = NULL;
if (m_pResManager->GenerateNodeByCfgID(eSpriteType_Cfg, Star97_Font_Room_Sit_Name, pUserName))
{
}
if (pUserName && tableSprite.m_pTableBK)
{
szBKSize = tableSprite.m_pTableBK->getContentSize();
pUserName->setString("");
pUserName->setPosition(ccp(szBKSize.width*0.5,0));
pUserName->setHorizontalAlignment(kCCTextAlignmentCenter);
pUserName->setVerticalAlignment(kCCVerticalTextAlignmentCenter);
tableSprite.m_pTableBK->addChild(pUserName);
seat.m_pNameLabel = pUserName;
}
tableSprite.m_vSeatSprites.push_back(seat);
}
return tableSprite;
}