コード例 #1
0
//定时执行分数自动增减
void CFScoreBoard::doAutoScore(ccTime dt){
    if(scorePerSec == 0 && ((int)dt%60)!=0){
        return;
    }
    this->score+=scorePerSec;
    int num = cun(score);
    for(int i = 0; i < num;i++){
        int slot = pow(10.0,i);
        int digital = (score/slot)%10;
        char* buffer = new char[5];
        sprintf(buffer, "%d", digital);
        CCLabelBMFont* pLabel =(CCLabelBMFont*) this->getChildByTag(i);
        if(!pLabel){
            pLabel =  CCLabelBMFont::labelWithString(buffer,"fonts/fonts.fnt");
            CCSize labelsize = pLabel->getContentSize();
            pLabel->setPosition(ccp(width-i*20,height/2));
            pLabel->setTag(i);
            this->addChild(pLabel);
        }else{
            pLabel->setString(buffer);
        }
        this->doChangeAnimation(scorePerSec);
        delete[] buffer;
    }
}
コード例 #2
0
//bit map font 
CCLabelBMFont* VGPLabel::createLabelBMFont( char *strName, char* fntFile, float width, cocos2d::CCPoint position, CCTextAlignment alignment, CCPoint imageOffset, int zOrder, int tag )
{
	CCLabelBMFont *label = CCLabelBMFont::create( strName, fntFile, width, alignment, imageOffset);
	label->setPosition( position ); 
	label->setZOrder( zOrder );
	label->setTag( tag );
	return label;
}
コード例 #3
0
void GameScene::showStartLabel() {
	CCLabelBMFont* startLabel = CCLabelBMFont::create("Touch to Start",
			FONT_TOUCH);
	startLabel->setPosition(
			ccp(g_visibleSize.width * 0.5, g_visibleSize.height * 0.5));
	startLabel->setTag(kTagStartLabel);
	this->addChild(startLabel);
	startLabel->runAction(Animations::topLabelAction());
}
コード例 #4
0
void GridLayer::InitScaleLabel()
{
   CCSize scrSize = CCDirector::sharedDirector()->getWinSize();
   char buffer[32];
   
   sprintf(buffer,"Scale\n%4.2f",Viewport::Instance().GetScale());
   
   CCLabelBMFont* label = CCLabelBMFont::create(buffer, "Arial_32_Green.fnt",100,kCCTextAlignmentCenter);
   label->setPosition(ccp(0.95f*scrSize.width,0.95f*scrSize.height));
   label->setTag(TAG_LABEL_SCALE);
   addChild(label);
}
コード例 #5
0
void GameScene::showScore() {
	//スコア
	CCLabelBMFont* score = dynamic_cast<CCLabelBMFont*>(this->getChildByTag(
			kTagScore));
	if (score) {
		score->removeFromParent();
	}

	CCLabelBMFont* label = dynamic_cast<CCLabelBMFont*>(this->getChildByTag(
			kTagScoreLabel));

	CCString* gameScore = CCString::createWithFormat("%d", getScore());
	score = CCLabelBMFont::create(gameScore->getCString(), FONT_ORANGE);
	score->setScale(TEXT_SCALE);
	score->setAnchorPoint(CCPointZero);
	score->setPosition(
			label->getPositionX() + label->getContentSize().width * TEXT_SCALE
					+ 10, label->getPositionY());
	score->setTag(kTagScore);
	this->addChild(score);
}
コード例 #6
0
void GameScene::showBallRemain() {
	//残りボール数
	CCLabelBMFont* remain = dynamic_cast<CCLabelBMFont*>(this->getChildByTag(
			kTagBallRemainCount));
	if (remain) {
		this->removeChild(remain);
	}

	CCLabelBMFont* label = dynamic_cast<CCLabelBMFont*>(this->getChildByTag(
			kTagBallRemainLabel));

	CCString* ballRemain = CCString::createWithFormat("%d", getBallRemain());
	remain = CCLabelBMFont::create(ballRemain->getCString(), FONT_ORANGE);
	remain->setScale(TEXT_SCALE);
	remain->setAnchorPoint(CCPointZero);
	remain->setPosition(
			label->getPositionX() + label->getContentSize().width * TEXT_SCALE
					+ 10, label->getPositionY());
	remain->setTag(kTagBallRemainCount);
	this->addChild(remain);
}
コード例 #7
0
ファイル: GameOver.cpp プロジェクト: jindaw/learn
void GameOver::initData()
{
    // clean Txt
    CCSprite* cleanSprite = CCSprite::createWithSpriteFrameName(rewardUI[kTypeClearn]);
    cleanSprite->setPosition(ccpAdd(m_ptCenter, ccp( 150, 100)));
    cleanSprite->setTag(kTypeClearn);
    cleanSprite->setOpacity(0);
    this->addChild(cleanSprite);
    
    // reward background
    CCSprite* rewardBGSprite = CCSprite::createWithSpriteFrameName(rewardUI[kTypeNomalBG]);
    rewardBGSprite->setPosition(ccpSub(m_ptCenter, ccp(0, 100)));
    rewardBGSprite->setTag(kTypeNomalBG);
    rewardBGSprite->setOpacity(0);
    this->addChild(rewardBGSprite);
    
    //reward score
    CCLabelBMFont * rewardScore = CCLabelBMFont::create("0", rewardUI[ktypeScore]);
    rewardScore->setAnchorPoint(ccp(0.5f, 0.5f));
    rewardScore->setPosition(ccpSub(m_ptCenter, ccp(0, 200)));
    rewardScore->setTag(ktypeScore);
    rewardScore->setOpacity(0);
    this->addChild(rewardScore);
}
コード例 #8
0
void LCCrossMatchGame::loadSprites()
{
	// check final game added by LEETAEHO on 111101
	// 두가지 체크 방법이 있음. 하나는 index의 끝 다른 하나는 배열이 비었을때, 일단은 인덱스로 체크
	if (m_iIndex >= m_pIndexArray->count()) {
		this->didFinishedGame();
		return;
	}
	
	// initialize
	for (int i=0; i<m_pLoadedSprites->count(); i++) 
	{
		CCNode* pNode = (CCNode*) m_pLoadedSprites->objectAtIndex(i);
		//pNode->removeFromParentAndCleanup(true);
		CCSequence* seq = CCSequence::actions(CCFadeOut::actionWithDuration(1.0f), 
											  CCCallFuncN::actionWithTarget(this, callfuncN_selector(LCCrossMatchGame::didSpriteAnimated)), 
											  NULL);
		pNode->runAction(seq);
	}
	m_pLoadedSprites->removeAllObjects();
	m_pCanvas->clear(0, 0, 0, 0);
	m_pDotSprites->removeAllObjects();
	m_pFinishedDotSprites->removeAllObjects();
	m_pImageArray->removeAllObjects();
	m_pTextArray->removeAllObjects();
	
	// load texts and images
	CCArray* textLabelArray = CCArray::array();
	CCArray* imageArray = CCArray::array();
	for (int i=0; i<this->getMaxNumberOfItems(); i++) 
	{
		// index 초과시 로딩 안함 added by LEETAEHO on 111101
		if (m_iIndex >= m_pIndexArray->count()) {
			CCLog("index was ended");
			break;
		}
		
		m_iIndex = (m_iIndex + m_pIndexArray->count()) % m_pIndexArray->count();
		
		// 이미지가 있는 단어만 가져오기
		CCSprite* imageSprite = this->getImageWithIndex(m_pIndexArray, m_iIndex);
		if (!imageSprite)
		{
			m_iIndex++;
			i--;
			continue;
		}
		imageSprite->setTag(m_iIndex);
		this->addChild(imageSprite, zIMAGE_SPRITE);
		imageArray->addObject(imageSprite);
		m_pLoadedSprites->addObject(imageSprite);
		
		CCLabelBMFont* textLabel = this->getTextLabelWithIndex(m_pIndexArray, m_iIndex);
		textLabel->setTag(m_iIndex);
		this->addChild(textLabel, zTEXT_LABEL);
		textLabelArray->addObject(textLabel);
		m_pLoadedSprites->addObject(textLabel);
		
		m_iIndex++;
	}
	
	// 배치
	this->arrangeComponents(textLabelArray, imageArray);
	
	//shuffle texts
	//this->shuffleNodes(textLabelArray);
	
	// add dots
	for (int i=0; i<imageArray->count(); i++) {
		CCSprite *imageSprite = (CCSprite *)imageArray->objectAtIndex(i);
		CCSprite *dotSprite = this->getDotSprite();
		dotSprite->setTag(imageSprite->getTag());
		dotSprite->setPosition(ccp(imageSprite->getPosition().x + this->getDotDistanceWithImage(), imageSprite->getPosition().y));
		this->addChild(dotSprite, zDOT_SPRITE);
		m_pDotSprites->addObject(dotSprite);
		m_pLoadedSprites->addObject(dotSprite);
	}
	
	for (int i=0; i<textLabelArray->count(); i++) {
		CCLabelAtlas *characterLabel = (CCLabelAtlas *)textLabelArray->objectAtIndex(i);
		CCSprite *dotSprite = this->getDotSprite();
		dotSprite->setTag(characterLabel->getTag());
		dotSprite->setPosition(ccp(characterLabel->getPosition().x + this->getDotDistanceWithTextLabel(), characterLabel->getPosition().y));
		this->addChild(dotSprite, zDOT_SPRITE);
		m_pDotSprites->addObject(dotSprite);
		m_pLoadedSprites->addObject(dotSprite);
	}
	
	// add arrays of images and texts
	m_pImageArray->addObjectsFromArray(imageArray);
	m_pTextArray->addObjectsFromArray(textLabelArray);
	
	
	// fade in animation
	for (int i=0; i < m_pLoadedSprites->count(); i++) 
	{
		CCSprite *loadedSprite = (CCSprite *)m_pLoadedSprites->objectAtIndex(i);
		loadedSprite->runAction(CCFadeIn::actionWithDuration(1.0f));
	} 
}