当前位置: 首页>>代码示例>>C++>>正文


C++ CCLabelTTF::getContentSize方法代码示例

本文整理汇总了C++中CCLabelTTF::getContentSize方法的典型用法代码示例。如果您正苦于以下问题:C++ CCLabelTTF::getContentSize方法的具体用法?C++ CCLabelTTF::getContentSize怎么用?C++ CCLabelTTF::getContentSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCLabelTTF的用法示例。


在下文中一共展示了CCLabelTTF::getContentSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: initWithSize

bool JunxianItem::initWithSize()
{
	
    
    if (!SNSTableViewCellItem::init()) {
		return false;
	}
    ResourceManager::sharedInstance()->bindTexture("sgplayerinfolayer/sgplayerinfolayer.plist", RES_TYPE_LAYER_UI, sg_junxianlayer);
    

    
     bgSize = CCSizeMake(600, 125);
//    bgSize=CCSizeMake(skewing(300), skewing(65));
    float viewWid = bgSize.width;
    float viewH = bgSize.height;
    
    CCScale9Sprite *frame2 = CCScale9Sprite::createWithSpriteFrameName("barrack_kuang.png");
    frame2->setPreferredSize(CCSizeMake(viewWid, viewH));
    this->addChild(frame2);
//    frame2->setPosition(spriteBg->getPosition());
    
    CCSprite *frame2bg = CCSprite::createWithSpriteFrameName("barrack_kuangbg.png");
    this->addChild(frame2bg, -1);
    frame2bg->setScaleX(viewWid/frame2bg->getContentSize().width);
    frame2bg->setScaleY(viewH/frame2bg->getContentSize().height);
    frame2bg->setPosition(frame2->getPosition());
    
    const char* fontName = FONT_BOXINFO;
    const int  fontsize = 26;
    condition = CCLabelTTF::create("", fontName, fontsize);
    condition->setAnchorPoint(ccp(0,0.5));
   
    buff = CCLabelTTF::create(str_JunxianLayer_str2, fontName, fontsize,CCSizeMake(fontsize*11,fontsize*3),kCCTextAlignmentLeft,kCCVerticalTextAlignmentTop);
    buff->setAnchorPoint(ccp(0,1));
    
    CCLabelTTF* hdtj = CCLabelTTF::create(str_JunxianLayer_str3, fontName, fontsize);
    hdtj->setPosition(ccp(-100,25));
    this->addChild(hdtj);
    
    condition->setPosition(ccpAdd(hdtj->getPosition(),ccp(hdtj->getContentSize().width/2,0)));
    this->addChild(condition);
    
    CCLabelTTF* jxjc = CCLabelTTF::create(str_JunxianLayer_str4, fontName, fontsize);
    jxjc->setPosition(ccpAdd(hdtj->getPosition(),ccp(0,-32)));
    jxjc->setColor(ccYELLOW);
    this->addChild(jxjc);
    
//    buff->setPosition(ccp(0,0));
//    buff->setString("sgadfsdafssfsafsafdfsafseagfdsfdsf");
    buff->setPosition(ccpAdd(jxjc->getPosition(),ccp(jxjc->getContentSize().width/2,jxjc->getContentSize().height/2)));
    buff->setColor(ccYELLOW);
    this->addChild(buff);
    
    


    
    //////////
	return true;
}
开发者ID:caoguoping,项目名称:warCraft,代码行数:60,代码来源:SGJunxianLayer.cpp

示例2: init

// on "init" you need to initialize your instance
bool GameScene::init()
{
    if ( !CCLayer::init() )
    {
        return false;
    }

    // 背景画像を設定する
    setBackGroundSprite();

    CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
    CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();

    CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
                                      "CloseNormal.png",
                                      "CloseSelected.png",
                                      this,
                                      menu_selector(GameScene::menuCloseCallback));

    pCloseItem->setPosition(ccp(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2 ,
                                origin.y + pCloseItem->getContentSize().height/2));

    CCMenu* pMenuClose = CCMenu::create(pCloseItem, NULL);
    pMenuClose->setPosition(CCPointZero);
    this->addChild(pMenuClose, 1);

    CCLabelTTF* pLabel = CCLabelTTF::create("GameScene", "Arial", 24);
    pLabel->setColor(ccc3((GLubyte)0,(GLubyte)0,(GLubyte)0));
    pLabel->setPosition(ccp(origin.x + visibleSize.width/2,
                            origin.y + visibleSize.height - pLabel->getContentSize().height));

    this->addChild(pLabel, 1);

    // 線引きのガイダンスを表示
    int fontSize = CCEGLView::sharedOpenGLView()->getDesignResolutionSize().height/320.0f * 18;
    CCLabelTTF *label = CCLabelTTF::create("指でなぞったラインを CCMotionStreak で描画します", "Helvetica", /*fontSize*/ 24);
    label->setColor(ccc3((GLubyte)0,(GLubyte)0,(GLubyte)0));
    label->setPosition(ccp(visibleSize.width / 2, visibleSize.height - label->getContentSize().height * 4));
    this->addChild(label);

    this->setTouchEnabled(true);	// タッチイベントを有効化
    this->setTouchMode(kCCTouchesOneByOne);		// シングルタッチ

//    CCSprite* pSprite = CCSprite::create("HelloWorld.png");
//    pSprite->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
//    this->addChild(pSprite, 0);

    // 次の画面へ遷移するボタン
    CCMenuItemImage *pNextItem = CCMenuItemImage::create(
                                     "HelloWorld.png",
                                     "HelloWorld_02.png",
                                     this,
                                     menu_selector(GameScene::buttonOnClickCallBack));
    pNextItem->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
    CCMenu* pMenuNext = CCMenu::create(pNextItem, NULL);
    pMenuNext->setPosition(CCPointZero);
    this->addChild(pMenuNext, 0);

    return true;
}
开发者ID:nitobe-gloops,项目名称:DemoApplication,代码行数:61,代码来源:GameScene.cpp

示例3: 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)) ;
}
开发者ID:fengmm521,项目名称:qipaiproject,代码行数:36,代码来源:YJGameModeLabel.cpp

示例4: ReadLgCell

void RWLViewDBSource::ReadLgCell(std::string asHead, LogicCell* algc)
{
	if(0 == algc->miType){
		CCLabelTTF* tlt = CCLabelTTF::create((asHead+algc->msText).c_str(), FNT_UI_LABEL, 24,CCSize(rw,0), kCCTextAlignmentLeft);
		tlt->retain();
		m_plength.push_back(tlt->getContentSize().height);
		CCLog("+++++++%f", tlt->getContentSize().height);
		m_height += tlt->getContentSize().height;
		data->addObject(tlt);		

		asHead += " ";
		return;
	}


	for(std::vector<LogicCell*>::iterator it = algc->mvChilds.begin(); it != algc->mvChilds.end(); ++it){
		if((*it)->miType == 0){
			asHead += " ";
			break;
		}
	}

	for(std::vector<LogicCell*>::iterator it = algc->mvChilds.begin(); it != algc->mvChilds.end(); ++it){
		ReadLgCell(asHead.c_str(), *it);
	}

}
开发者ID:steinkrausls,项目名称:cocotd,代码行数:27,代码来源:RWLViewDBSource.cpp

示例5: updatePhysics

void WordTreeScene::updatePhysics(Word* word) {
    cpShape* shape = word->getShape();
    if( shape!=NULL ) {
        cpSpaceRemoveShape(ChipmunkManager::getInstance()->getSpace(), shape);
        cpShapeDestroy(shape);
        word->setShape(NULL);
    }
    
    cpBody* body = word->getBody();
    if( body!=NULL ) {
        cpSpaceRemoveBody(ChipmunkManager::getInstance()->getSpace(), body);
        cpBodyDestroy(body);
        word->setBody(NULL);
    }
    
    CCLabelTTF* targetLabel = word->getLabel();
    CCPoint pos = targetLabel->getPosition();
    CCSize contentSize = targetLabel->getContentSize();
    
    // init body
    body = cpBodyNew(1, INFINITY);
    body->p = cpv(targetLabel->getPosition().x, targetLabel->getPosition().y);
    cpSpaceAddBody(ChipmunkManager::getInstance()->getSpace(), body);
    
    float size = MAX(targetLabel->getContentSize().width, targetLabel->getContentSize().height);
    
    shape = cpBoxShapeNew(body, size+size*0.3f, size+size*0.3f);
    cpSpaceAddShape(ChipmunkManager::getInstance()->getSpace(), shape);
    
    word->setBody(body);
    word->setShape(shape);
}
开发者ID:GoodMorningCody,项目名称:WordTree,代码行数:32,代码来源:WordTreeScene.cpp

示例6: CCSize

LayerChanToast::LayerChanToast(string message){
	vector<string> lstRegex;
	for( int i = 1; i <= 16; i++ ){
		lstRegex.push_back( CCString::createWithFormat("(%d)", i)->getCString() );
	}

	this->setAnchorPoint(ccp(0, 0));
	// text
	cocos2d::ui::RichText* label = cocos2d::ui::RichText::create();
	label->setAnchorPoint(ccp(0, 0));
	label->setPosition(ccp(0, HEIGHT_DESIGN / 3.5));

	vector<string> lstContents = mUtils::splitStringByListRegex(message, lstRegex);
	int wLabel = 0, hLabel = 0;
	for( int i = 0; i < lstContents.size(); i++ ){
		bool check = false;
		int j = 0;
		for( j = 0; j < lstRegex.size(); j++ )
			if( lstRegex.at(j) == lstContents.at(i) ){
				check = true;
				break;
			}
			if( check ){
				CCArmature *armature = CCArmature::create(CCString::createWithFormat("onion%d", 1)->getCString());
				armature->getAnimation()->playByIndex(j);
				cocos2d::ui::RichElementCustomNode* recustom = cocos2d::ui::RichElementCustomNode::create(1, ccWHITE, 255, armature);
				label->pushBackElement(recustom);
				wLabel += 50;
				hLabel = 55;
			}else{
				CCLabelTTF *l = CCLabelTTF::create(lstContents.at(i).c_str(), "Arial", 16);
				l->setColor(ccc3(204, 16, 85));
				cocos2d::ui::RichElementText* re1 = cocos2d::ui::RichElementText::create(1, ccWHITE, 255, lstContents.at(i).c_str(), "Arial", 16);
				label->pushBackElement(re1);
				wLabel += l->getContentSize().width;
				hLabel = hLabel > 50 ? 55 : l->getContentSize().height;
			}
	}
	this->addChild(label, 1, 0);

	CCSize sizeDesign = CCSize(169, 30);
	CCSpriteBatchNode *batchNode = CCSpriteBatchNode::create("chats/framechat_a.png");
	CCScale9Sprite *blocks = CCScale9Sprite::create();
	blocks ->updateWithBatchNode(batchNode , CCRect(0, 0, sizeDesign.width, sizeDesign.height), false, CCRect(10, 10, sizeDesign.width - 20, sizeDesign.height - 20));

	CCSize size = CCSizeMake(wLabel + 10, hLabel + 5);
	blocks ->setContentSize(size);
	blocks->setAnchorPoint(ccp(0.5, 0.5));
	blocks->setPosition(ccp(label->getPositionX() + wLabel / 2, label->getPositionY() + hLabel / 2));

	blocks->setColor(ccc3(84, 81, 69));
	blocks->setOpacity(200);
	this->setPosition(ccp((WIDTH_DESIGN - size.width) / 2, 100));
	// add
	this->addChild(blocks);
}
开发者ID:mrktj,项目名称:iCasino_v2,代码行数:56,代码来源:LayerChanToast.cpp

示例7: init

// on "init" you need to initialize your instance
bool HelloWorld::init()
{
	//////////////////////////////
    // 1. super init first
    if( !CCLayer::init())//RGBA
    {
        return false;
    }

    CCSize visibleSize = CCDirector::sharedDirector()->getWinSize();
    CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
	CCSize winsize = CCDirector::sharedDirector()->getWinSize();

	/*
	CCMenuItemImage *pNewGame = CCMenuItemImage::create("newgame.png", "newgame.png", this, menu_selector(HelloWorld::menuCloseCallback));
	CCMenu *pMenu = CCMenu::create(pNewGame);
	pMenu->setPosition(ccp(winsize.width/2, pMenu->getContentSize().height));
	this->addChild(pMenu);*/
    
    CCLabelTTF* pLabel = CCLabelTTF::create("Brick Breaker", "Syncopate", 36);
    
    // position the label on the center of the screen
    pLabel->setPosition(ccp(origin.x + winsize.width/2,
                            origin.y + winsize.height - pLabel->getContentSize().height));
	pLabel->setColor(ccORANGE);

    // add the label as a child to this layer
    this->addChild(pLabel, 1);
	CCLabelTTF* pLabel2 = CCLabelTTF::create("by David Grayson", "Syncopate", 30);
    
    // position the label on the center of the screen
    pLabel2->setPosition(ccp(origin.x + winsize.width/2,
                            origin.y + winsize.height - (pLabel->getContentSize().height)*2));
	pLabel2->setColor(ccORANGE);

    // add the label as a child to this layer
    this->addChild(pLabel2, 1);
	

	new_game_button = CCSprite::create("newgame2.png");
	//new_game_button->setScaleX(visibleSize.width/1000);
	//new_game_button->setScaleY(visibleSize.height/1000);
	new_game_button->setScale(1.0f);
	new_game_button->setPosition(ccp(winsize.width/2, new_game_button->getContentSize().height*4));
	this->addChild(new_game_button);

	option_button = CCSprite::create("options2.png");
	//option_button->setScaleX(visibleSize.width/1000);
	//option_button->setScaleY(visibleSize.height/1000);
	option_button->setScale(1.0f);
	option_button->setPosition(ccp(winsize.width/2, option_button->getContentSize().height*2));
	this->addChild(option_button);
    
    this->setTouchEnabled(true);
    return true;
}
开发者ID:dkgrayson,项目名称:BrickBreaker,代码行数:57,代码来源:HelloWorldScene.cpp

示例8: init

bool GameOverLayer::init()
{
	bool bRet = false;
	do
	{
		CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
		CCPoint visibleOrigin = CCDirector::sharedDirector()->getVisibleOrigin();
		CCSprite* gameOverBg = CCSprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("gameover.png"));
		gameOverBg->setPosition(ccp(visibleOrigin.x + visibleSize.width/2, visibleOrigin.y + visibleSize.height/2));
		this->addChild(gameOverBg);

		passScoreItem=CCLabelBMFont::create("0", "font/font.fnt");
		passScoreItem->setColor(ccc3(143, 146, 147));  //灰白色
		passScoreItem->setAnchorPoint(ccp(0.5, 0.5));
		passScoreItem->setPosition(ccp(visibleOrigin.x + visibleSize.width/2, visibleOrigin.y + visibleSize.height/2));
		CCString* strScore = CCString::createWithFormat("%d", this->thisTimeGetscore);  //格式化为字符串 
		passScoreItem->setString(strScore->m_sString.c_str());  //从CCString中获得char*,更新分数
		this->addChild(passScoreItem);

		CCLabelTTF* highestScoreItem = CCLabelTTF::create("", "Arial", 24);
		highestScoreItem->setColor(ccc3(3, 3, 3));  //黑色
		CCString* highestScore=CCString::createWithFormat("highestScore:%d", GameOverLayer::highestHistoryScore);
		highestScoreItem->setString(highestScore->m_sString.c_str());
		highestScoreItem->setPosition(ccp(visibleOrigin.x + highestScoreItem->getContentSize().width/2,
										visibleOrigin.y + visibleSize.height - highestScoreItem->getContentSize().height));
		this->addChild(highestScoreItem);

		if (thisTimeGetscore > GameOverLayer::highestHistoryScore)
		{  
			CCUserDefault::sharedUserDefault()->setIntegerForKey("HighestScore", thisTimeGetscore);  //修改存档
			CCUserDefault::sharedUserDefault()->flush();
			GameOverLayer::highestHistoryScore = thisTimeGetscore;  //最高分重新设定
		}

		CCDelayTime* delay = CCDelayTime::create(1.0f);  
		CCScaleTo* scaleBig = CCScaleTo::create(1.0f, 3.0f);  
		CCScaleTo* scaleLittle = CCScaleTo::create(0.3f, 2.0f);  
		CCFiniteTimeAction* sequence = CCSequence::create(delay, scaleBig, scaleLittle, NULL);
		passScoreItem->runAction(sequence);

		CCSprite* normalPause = CCSprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_finish.png"));
		CCSprite* pressedPause = CCSprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_finish.png"));
    	CCMenuItemImage* restartGame = CCMenuItemImage::create();
		restartGame->initWithNormalSprite(normalPause, pressedPause, NULL, this, menu_selector(GameOverLayer::restartGame));
		restartGame->setPosition(ccp(visibleOrigin.x + visibleSize.width - normalPause->getContentSize().width,
									 visibleOrigin.y + normalPause->getContentSize().height));

		CCMenu* menu = CCMenu::create(restartGame, NULL);
		menu->setPosition(CCPointZero);
		this->addChild(menu, 10);
		
		bRet = true;
	}while(0);

	return bRet;
}
开发者ID:rzzz,项目名称:cocosAirPlane,代码行数:56,代码来源:GameOverLayer.cpp

示例9: tableCellSizeForIndex

CCSize ListViewLayer::tableCellSizeForIndex(CCTableView *table,unsigned int idx)
{
    const char * str = aVect[idx].c_str();
    
    CCLabelTTF *pLabel = CCLabelTTF::create(str, "Arial", 20.0,CCSizeMake(table->getContentSize().width, 0), kCCTextAlignmentLeft);
    CCLOG("%f",pLabel->getContentSize().height);
    
    return pLabel->getContentSize();

}
开发者ID:liuyuyefz,项目名称:GreTest,代码行数:10,代码来源:ListViewLayer.cpp

示例10: showImmediately

void AchievementNotification::showImmediately(Achievement a)
{
	mShowing = true;
	CCTexture2D* tex = CCTextureCache::sharedTextureCache()->textureForKey(fileName.c_str());
	if (tex == NULL)
	{
		tex = CCTextureCache::sharedTextureCache()->addImage(fileName.c_str());
	}
	CCSize winSize = CCDirector::sharedDirector()->getWinSize();


	CCScale9Sprite* pBoard = CCScale9Sprite::create(CCRectMake(tex->getContentSize().width/2, 0, 2, tex->getContentSize().height), fileName.c_str());
	addChild(pBoard,0,Tag_Board);
	pBoard->setPosition(ccp(winSize.width/2,winSize.height + pBoard->getContentSize().height) );

	CCSprite* pJinBei = CCSprite::create(ResManager::getManager()->getFilePath(g_public+"CJ_icon_jiangbei.png").c_str());
	pBoard->addChild(pJinBei, 1);
	pJinBei->setPosition(ccp(pJinBei->getContentSize().width, pBoard->getContentSize().height/2));

	CCLabelTTF* pName = CCLabelTTF::create(a.name.c_str(), fontStr_KlavikaBold, 40);
	pName->setColor(fontColor_Acheivement_TTF);
	CCSprite* pIcon = CCSprite::create(ResManager::getManager()->getFilePath(g_public+"CJ_icon_wancheng.png").c_str());
	int x = pName->getContentSize().width + pIcon->getContentSize().width - 420;
	if (x > 0)
	{
		pBoard->setContentSize(ccp(pBoard->getContentSize().width+x, pBoard->getContentSize().height));
	}
	pBoard->addChild(pName);

	int xoffset = 10;

	pName->setPosition(ccp(pBoard->getContentSize().width/2 + pIcon->getContentSize().width/2 + xoffset, pBoard->getContentSize().height/2));

	pBoard->addChild(pIcon);
	pIcon->setPosition(ccp(pName->getPositionX() - pName->getContentSize().width/2 - pIcon->getContentSize().width/2 - xoffset, pName->getPositionY()));

	Achievement* achievementCopy = new Achievement(a);
//	*achievementCopy = a;
	temp_Must_Delete.insert(temp_Must_Delete.end(),achievementCopy);

	pBoard->runAction(CCSequence::create(
		CCMoveTo::create(0.5f,ccp(pBoard->getPositionX(),winSize.height-pBoard->getContentSize().height/2)),
		CCDelayTime::create(0.1f),
		CCCallFuncND::create(this,SEL_CallFuncND(&AchievementNotification::boardShowing),achievementCopy),
		CCDelayTime::create(1.3f),
		CCMoveTo::create(0.2f,ccp(pBoard->getPositionX(),winSize.height+pBoard->getContentSize().height)),
		CCFadeTo::create(0.1f,0),
		CCCallFuncN::create(this,SEL_CallFuncN(&AchievementNotification::boardShowEnd)),NULL));

	createPar(ccp(winSize.width/2,winSize.height),parFileName.c_str(),pBoard->getContentSize().width * 1.2f,pBoard->getContentSize().height);

	Music::sharedMusicPlayer()->playEffectSound("achievement.wav");

	CCLog("AchievementNotification::showImmediately name = %s" ,a.name.c_str());
}
开发者ID:SongCF,项目名称:game-LostStar,代码行数:55,代码来源:AchievementNotification.cpp

示例11: InitDialog

bool HSGoldInadequateDialog::InitDialog()
{
	CCSprite* pBackground = CCSprite::create("Image/SelectChannel/goumaijinbidikuang.png");
	pBackground->setPosition(ccp(307,480));
	this->addChild(pBackground);


	CCSprite* pGoldFrame = CCSprite::create("Image/SelectChannel/Mingziditu.png");
	pGoldFrame->setPosition(ccp(236,202));
	pBackground->addChild(pGoldFrame);

	CCSprite* pMoneyFrame = CCSprite::create("Image/SelectChannel/Mingziditu.png");
	pMoneyFrame->setPosition(ccp(520,202));
	pBackground->addChild(pMoneyFrame);

	const message::PropInfoData* pPropInfodata = HS_GAME_CACHE()->GetPropInfoData();

	for (int i =0;i<pPropInfodata->buygoldlist_size();++i)
	{
		int temp = pPropInfodata->buygoldlist(i).gold_number();
		if ((int)m_buyGold.gold_number() < temp)
		{
			m_buyGold = pPropInfodata->buygoldlist(i);
		}
		if (temp > HS_GAME_CACHE()->GetGold())
		{
			m_buyGold = pPropInfodata->buygoldlist(i);
			break;
		}
	}


	CCLabelTTF* pGoldTTF = CCLabelTTF::create(CCString::createWithFormat("%d",m_buyGold.gold_number())->getCString(),HS_FONT_HuaKang,36.f);
	pGoldTTF->setAnchorPoint(HS_ANCHOR_L_CENTER);
	pGoldTTF->setPosition(ccp(0,pGoldTTF->getContentSize().height - pGoldTTF->getFontSize() / 2.f));
	pGoldFrame->addChild(pGoldTTF);

	CCLabelTTF* pMoneyTTF = CCLabelTTF::create(CCString::createWithFormat("%d",m_buyGold.money())->getCString(),HS_FONT_HuaKang,36.f);
	pMoneyTTF->setAnchorPoint(HS_ANCHOR_L_CENTER);
	pMoneyTTF->setPosition(ccp(0,pMoneyTTF->getContentSize().height - pMoneyTTF->getFontSize() / 2.f));
	pMoneyFrame->addChild(pMoneyTTF);

	CCMenuItem* pGoRoomItem = CCMenuItemImage::create("Image/SelectChannel/dibeilvchang_01.png","Image/SelectChannel/dibeilvchang_02.png",this,menu_selector(HSGoldInadequateDialog::Call_GoRoom));
	pGoRoomItem->setPosition(ccp(169,322));
	this->PushMenu(pGoRoomItem);

	CCMenuItem* pBuyItem = CCMenuItemImage::create("Image/SelectChannel/goumai_01.png","Image/SelectChannel/goumai_02.png",this,menu_selector(HSGoldInadequateDialog::Call_Buy));
	pBuyItem->setPosition(ccp(456,322));
	this->PushMenu(pBuyItem);


	return true;
}
开发者ID:wanggan768q,项目名称:GameWork,代码行数:53,代码来源:HSGoldInadequateDialog.cpp

示例12: createPerson

CCSprite* CreditsScreen::createPerson(const std::string& name, const std::string& twitterLink, const std::string& fbLink)
{
    const float iconSize = 32;
    
    bool useTwitter = !twitterLink.empty();
    bool useFB = !fbLink.empty();
    
    CCSprite* person = CCSprite::create();
    
    CCLabelTTF* nameLabel = CCLabelTTF::create(name.c_str(), default_font.c_str(), FONT_SIZE_PERSON);
    nameLabel->setPositionX(nameLabel->getContentSize().width / 2);
    
    float totalWidth = nameLabel->getContentSize().width;
    float totalHeight = MAX(nameLabel->getContentSize().height, iconSize);
    
    if(useTwitter || useFB){
        totalWidth += PADDING_AFTER_NAME;
    }
    
    if(useTwitter){
        totalWidth += iconSize + PADDING_PERSON;
        
        urls.push_back(twitterLink);
        Button* twitterButton = ButtonFactory::imageButton(TWITTER_ICON_INACTIVE, TWITTER_ICON_PRESSED, new Handler(this, callfuncD_selector(CreditsScreen::openURL), (void*)(urls.size() - 1)), BUTTON_PRIORITY);
        twitterButton->setPositionX(nameLabel->getPositionX() + totalWidth - iconSize - nameLabel->getContentSize().width/2);
        twitterButton->setPositionY(totalHeight / 2);

        person->addChild(twitterButton);
    }
    
    if(useFB) {
        totalWidth += iconSize + PADDING_PERSON;

        urls.push_back(fbLink);
        Button* fbButton = ButtonFactory::imageButton(FB_ICON_INACTIVE, FB_ICON_PRESSED, new Handler(this, callfuncD_selector(CreditsScreen::openURL), (void*)(urls.size() - 1)), BUTTON_PRIORITY);
        
        fbButton->setPositionX(nameLabel->getPositionX() + totalWidth - iconSize - nameLabel->getContentSize().width/2);
        fbButton->setPositionY(totalHeight / 2);
        
        person->addChild(fbButton);
    }
    
    person->setContentSize(CCSizeMake(totalWidth, totalHeight));
    nameLabel->setPositionY(totalHeight / 2);
    person->addChild(nameLabel);
    
    return person;
}
开发者ID:Stals,项目名称:TilesFight,代码行数:48,代码来源:CreditsScreen.cpp

示例13: createDamageIndicator

void SwarmGame::createDamageIndicator(const EntitySprite& es)
{
   int damageTaken = es.m_entity->mobileStats().lastReducedHitPoints();

   if ( damageTaken )
   {
      CCPoint startingPos( es.m_sprite->getPosition().x + es.m_sprite->getContentSize().width/2, es.m_sprite->getPosition().y + es.m_sprite->getContentSize().height );
      std::stringstream ss;
      CCLabelTTF* lblDmg = NULL;
      
      ss << (damageTaken < 0 ? "+" : "-") << damageTaken;
      lblDmg = CCLabelTTF::labelWithString(ss.str().c_str(), "Arial", 12);
      lblDmg->setColor( ccc3(255, 0, 0) );
      startingPos.x -= lblDmg->getContentSize().width/2;
      lblDmg->setPosition( startingPos );
      lblDmg->setAnchorPoint( ccp(0,0) );
      m_mapLayer->addChild(lblDmg);

      CCSequence* floater = CCSequence::actionOneTwo( CCMoveTo::actionWithDuration( 1.0f, CCPoint( startingPos.x, startingPos.y + 50 ) ), CCCallFuncN::actionWithTarget( this, callfuncN_selector(SwarmGame::onDamageFloaterDone) ) );
      lblDmg->runAction( floater );

      es.m_entity->mobileStats().reset();

      // if the sprite is taking damage, then colour it red
      es.m_sprite->setColor(ccc3(255, 128, 128));
   }
   else
   {
      // if not damage is taken, reset the tint
      es.m_sprite->setColor(ccc3(255, 255, 255));
   }
}
开发者ID:BGCX261,项目名称:zombieswarmer-svn-to-git,代码行数:32,代码来源:SwarmGame.cpp

示例14: while

bool CCLayer2::init()
{
	bool bRet=false;
	do 
	{
		CC_BREAK_IF(!CCLayer::init());

		CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
		CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();

		CCLabelTTF* pLabel = CCLabelTTF::create("Hello Layer2", "Arial", 30);

		// position the label on the center of the screen
		pLabel->setPosition(ccp(origin.x + visibleSize.width/2,
			origin.y + visibleSize.height - pLabel->getContentSize().height));

		// add the label as a child to this layer
		this->addChild(pLabel, 1);

		// add "HelloWorld" splash screen"
		CCSprite* pSprite = CCSprite::create("HelloWorld.png");
		pSprite->setScale(0.8);

		// position the sprite on the center of the screen
		pSprite->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));

		// add the sprite as a child to this layer
		this->addChild(pSprite, 0);
		bRet=true;
	} while (0);
	return bRet;
}
开发者ID:980538137,项目名称:cocos2dx-demo,代码行数:32,代码来源:CLayer2.cpp

示例15: init

// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    if ( !CCLayer::init() )
    {
        return false;
    }
    CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
                                        "CloseNormal.png",
                                        "CloseSelected.png",
                                        this,
                                        menu_selector(HelloWorld::menuCloseCallback));
    
	pCloseItem->setPosition(ccpAdd(VisibleRect::rightBottom(), 
	                        	ccp(-pCloseItem->getContentSize().width/2, pCloseItem->getContentSize().height/2)));
	
    CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
    pMenu->setPosition(CCPointZero);
    this->addChild(pMenu, 1);

    CCLabelTTF* pLabel = CCLabelTTF::create("Hello World", "Arial", SCALE_FACTOR * 24);
	pLabel->setPosition(ccpAdd(VisibleRect::top(),
                            ccp(0, -pLabel->getContentSize().height)));
    this->addChild(pLabel, 1);

    CCSprite* pSprite = CCSprite::create("HelloWorld.png");
	pSprite->setPosition(VisibleRect::center());
    this->addChild(pSprite, 0);

	CCSprite *pLogoSprite = CCSprite::create("icon.png");
	pLogoSprite->setAnchorPoint( ccp(0, 0.5) );
	pLogoSprite->setPosition(ccpAdd(VisibleRect::left(), ccp(50, 0)));
	this->addChild(pLogoSprite, 0);

    return true;
}
开发者ID:wwb0709,项目名称:feichuan,代码行数:36,代码来源:HelloWorldScene.cpp


注:本文中的CCLabelTTF::getContentSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。