Exemple #1
0
//ラベル表示
void GameScene::showLabel()
{
    Size bgSize = m_background->getContentSize();
    
    //残数表示
    int tagsForLabel[] = {kTagRedLabel, kTagBlueLabel, kTagYellowLabel, kTagGreenLabel, kTagGrayLabel};
    const char* fontNames[] = {FONT_RED, FONT_BLUE, FONT_YELLOW, FONT_GREEN, FONT_GRAY};
    float heightRate[] = {0.61, 0.51, 0.41, 0.31, 0.21};
    
    //コマの種類のループ
    vector<kBlock>::iterator it = blockTypes.begin();
    while (it != blockTypes.end()) {
        //コマ残数表示
        long count = m_blockTags[*it].size();
        const char* countStr = ccsf("%02ld", count);
        
        LabelBMFont* label = (LabelBMFont*)m_background->getChildByTag(tagsForLabel[*it]);
        if (!label)
        {
            //コマ残数表示
            label = LabelBMFont::create(countStr, fontNames[*it]);
            label->setPosition(ccp(bgSize.width * 0.78, bgSize.height * heightRate[*it]));
            m_background->addChild(label, kZOrderLabel, tagsForLabel[*it]);
        }
        else
        {
            label->setString(countStr);
        }
        it++;
    }
    
    //スコア表示
    const char* scoreStr = ccsf("%d", m_score);
    LabelBMFont* scoreLabel = (LabelBMFont*)m_background->getChildByTag(kTagScoreLabel);
    if (!scoreLabel)
    {
        
        //スコア生成
        scoreLabel = LabelBMFont::create(scoreStr, FONT_WHITE);
        scoreLabel->setPosition(ccp(bgSize.width * 0.78, bgSize.height * 0.75));
        m_background->addChild(scoreLabel, kZOrderLabel, kTagScoreLabel);
    }
    else
    {
        scoreLabel->setString(scoreStr);
    }
    
}
Exemple #2
0
void LayerGameMain::updateBigBoomCount(int bigBoomCount)
{
	String strBoomCount;
	Sprite * norBoom = Sprite::createWithSpriteFrameName("bomb.png");
	Sprite * selBoom = Sprite::createWithSpriteFrameName("bomb.png");
	if (bigBoomCount < 0)
	{
		return;
	}
	else if (bigBoomCount == 0)
	{
		if (this->getChildByTag(TAG_BIGBOOM))
		{
			this->removeChildByTag(TAG_BIGBOOM,true);
		}
		if (this->getChildByTag(TAG_BIGBOOMCOUNT))
		{
			this->removeChildByTag(TAG_BIGBOOMCOUNT,true);
		}
	}
	else if (bigBoomCount == 1)
	{
		if ( !(this->getChildByTag(TAG_BIGBOOM)) )
		{
			MenuItemSprite * boomItem = MenuItemSprite::create(norBoom,
															   selBoom,
															   CC_CALLBACK_1(LayerGameMain::boomMenuCallback,this));
			boomItem->setPosition(norBoom->getContentSize().width/2,norBoom->getContentSize().height/2);
			Menu * boomMenu = Menu::create(boomItem,nullptr);
			boomMenu->setPosition(Point::ZERO);
			this->addChild(boomMenu,0,TAG_BIGBOOM);
		}
		if ( !(this->getChildByTag(TAG_BIGBOOMCOUNT)) )
		{
			strBoomCount.initWithFormat("X %d",bigBoomCount);
			LabelBMFont * labelBoomCount = LabelBMFont::create(strBoomCount.getCString(),"font/font.fnt");
			labelBoomCount->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT);
			labelBoomCount->setPosition(Point(norBoom->getContentSize().width,norBoom->getContentSize().height - 30));
			this->addChild(labelBoomCount,0,TAG_BIGBOOMCOUNT);
		}
	}
	else if (bigBoomCount > 1 && bigBoomCount < MAX_BIGBOOM_COUNT)
	{
		strBoomCount.initWithFormat("X %d",bigBoomCount);
		LabelBMFont * labelCount = (LabelBMFont *)this->getChildByTag(TAG_BIGBOOMCOUNT);
		labelCount->setString(strBoomCount.getCString());
	}
}
Exemple #3
0
void LayerGameMain::boomMenuCallback(cocos2d::Ref * ref)
{
	_bigBoomCount--;
	String strBoomCount;
	strBoomCount.initWithFormat("X %d",_bigBoomCount);
	LabelBMFont * labelCount = (LabelBMFont *)this->getChildByTag(TAG_BIGBOOMCOUNT);
	labelCount->setString(strBoomCount.getCString());

	_score += _enemyLayer->_smallVec.size()*SMALL_SCORE;
	_score += _enemyLayer->_midVec.size()*MID_SCORE;
	_score += _enemyLayer->_bigVec.size()*BIG_SCORE;
	_controlLayer->updateScore(_score);
	_enemyLayer->removeAllEnemy();
	if (_bigBoomCount == 0)
	{
		this->removeChildByTag(TAG_BIGBOOM);
		this->removeChildByTag(TAG_BIGBOOMCOUNT);
	}
}
Exemple #4
0
//ハイスコアラベルの表示
void GameScene::showHighScoreLabel()
{
    Size bgSize = m_background->getContentSize();
    
    //ハイスコア表示
    int highScore = UserDefault::getInstance()->getIntegerForKey(KEY_HIGHSCORE, 0);
    const char* highScoreStr = ccsf("%d", highScore);
    LabelBMFont* highScoreLabel = (LabelBMFont*)m_background->getChildByTag(kTagHighScoreLabel);
    if(!highScoreLabel)
    {
        //ハイスコア生成
        highScoreLabel = LabelBMFont::create(highScoreStr, FONT_WHITE);
        highScoreLabel->setPosition(ccp(bgSize.width * 0.78,bgSize.height * 0.87));
        m_background->addChild(highScoreLabel, kZOrderLabel, kTagHighScoreLabel);
    }
    else
    {
        highScoreLabel->setString(highScoreStr);
    }
    
}
//------------------------------------------------------------------
//
// AtlasBitmapColor
//
// Use any of these editors to generate BMFonts:
//     http://glyphdesigner.71squared.com/ (Commercial, Mac OS X)
//     http://www.n4te.com/hiero/hiero.jnlp (Free, Java)
//     http://slick.cokeandcode.com/demos/hiero.jnlp (Free, Java)
//     http://www.angelcode.com/products/bmfont/ (Free, Windows only)
//
//------------------------------------------------------------------
AtlasBitmapColor::AtlasBitmapColor()
{
    auto s = Director::getInstance()->getWinSize();
    
    LabelBMFont* label = NULL;
    label = LabelBMFont::create("Blue", "fonts/bitmapFontTest5.fnt");
    label->setColor( Color3B::BLUE );
    addChild(label);
    label->setPosition( Point(s.width/2, s.height/4) );
    label->setAnchorPoint( Point(0.5f, 0.5f) );

    label = LabelBMFont::create("Red", "fonts/bitmapFontTest5.fnt");
    addChild(label);
    label->setPosition( Point(s.width/2, 2*s.height/4) );
    label->setAnchorPoint( Point(0.5f, 0.5f) );
    label->setColor( Color3B::RED );

    label = LabelBMFont::create("G", "fonts/bitmapFontTest5.fnt");
    addChild(label);
    label->setPosition( Point(s.width/2, 3*s.height/4) );
    label->setAnchorPoint( Point(0.5f, 0.5f) );
    label->setColor( Color3B::GREEN );
    label->setString("Green");
}