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


C++ LabelBMFont::setPosition方法代码示例

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


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

示例1: showLabel

//ラベル表示
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);
    }
    
}
开发者ID:mrt168,项目名称:nyanzame,代码行数:49,代码来源:GameScene.cpp

示例2: showRestartMenu

void HelloWorld::showRestartMenu()
{
    Size winSize = Director::getInstance()->getWinSize();

    const char *message;
    if (_won)
    {
        message = "You win!";
    }
    else
    {
        message = "You lose!";
    }

    LabelBMFont *label = LabelBMFont::create(message, "Arial.fnt");
    label->setScale(0.1f);
    label->setPosition(winSize.width / 2, winSize.height * 0.6f);
    this->addChild(label);

    LabelBMFont *restartLabel = LabelBMFont::create("Restart", "Arial.fnt");
    MenuItemLabel *restartItem = MenuItemLabel::create(restartLabel, [](Object *sender){
        Director::getInstance()->replaceScene(TransitionZoomFlipX::create(0.5f, HelloWorld::createScene()));
    });
    restartItem->setScale(0.1f);
    restartItem->setPosition(winSize.width / 2, winSize.height * 0.4f);

    Menu *menu = Menu::createWithItem(restartItem);
    menu->setPosition(Point::ZERO);
    this->addChild(menu);

    restartItem->runAction(ScaleTo::create(0.5f, 1.0f));
    label->runAction(ScaleTo::create(0.5f, 1.0f));
}
开发者ID:Kurukshetran,项目名称:Cocos2dxGame,代码行数:33,代码来源:HelloWorldScene.cpp

示例3: endScene

void HelloWorld::endScene(EndReason endReason) {
	if (_gameOver)
		return;
	_gameOver = true;

	//存储分数
	setHighestHistorySorce();
	gScore = 0;

	auto winSize = Director::getInstance()->getWinSize();
	char message[10] = "You Win";
	if (endReason == KENDREASONLOSE)
		strcpy(message, "You Lose");
	LabelBMFont * label;
	label = LabelBMFont::create(message,"fonts/Arial.fnt");
	label->setScale(0.1);
	label->setPosition(Point(winSize.width / 2, winSize.height*0.6));
	this->addChild(label);

	LabelBMFont * restartLabel;
	restartLabel = LabelBMFont::create("Restart", "fonts/Arial.fnt");
	auto *restartItem = MenuItemLabel::create(restartLabel,CC_CALLBACK_1(HelloWorld::restartTapped,this));
	restartItem->setScale(0.1);
	restartItem->setPosition(Point(winSize.width / 2, winSize.height*0.4));

	Menu *menu = Menu::create(restartItem, NULL);
	menu->setPosition(Point::ZERO);
	this->addChild(menu);

	// clear label and menu
	restartItem->runAction(ScaleTo::create(0.5, 1.0));
	label->runAction(ScaleTo::create(0.5, 1.0));
	// Terminate update callback
	this->unscheduleUpdate();
}
开发者ID:linger2334,项目名称:SpaceGame,代码行数:35,代码来源:HelloWorldScene.cpp

示例4: init

// on "init" you need to initialize your instance
bool OptionsMenu::init()
{
    Size visibleSize = CCDirector::sharedDirector()->getVisibleSize();
    Vec2 origin = CCDirector::sharedDirector()->getVisibleOrigin();

    scrollingBgLayer = new ScrollingBgLayer(3.0);
    this->addChild(scrollingBgLayer);


    LabelBMFont *nameLabel = LabelBMFont::create("Options Menu","PixelFont.fnt");
    nameLabel->setPosition(visibleSize.width/2, visibleSize.height * 0.8);
    this->addChild(nameLabel);

    MenuItemImage *presetItem = MenuItemImage::create("_bookgame_UI__resume.png",
                                "_bookgame_UI__resume.png",
                                CC_CALLBACK_1(OptionsMenu::reset, this));
    presetItem->setPosition(ccp(visibleSize.width/2 - visibleSize.width * 0.125,  visibleSize.height * 0.5));


    MenuItemImage *pmainMenuItem = MenuItemImage::create("_bookgame_UI_mainmenu.png",
                                   "_bookgame_UI_mainmenu.png",
                                   CC_CALLBACK_1(OptionsMenu::mainMenu, this));
    pmainMenuItem->setPosition(Vec2(visibleSize.width/2 + visibleSize.width * 0.125, visibleSize.height * 0.5 ));



    //sound onoff items
    soundOnItem = MenuItemImage::create("_bookgame_UI_soundON.png","_bookgame_UI_soundON.png", this,NULL);
    soundOffItem = MenuItemImage::create("_bookgame_UI_soundOFF.png","_bookgame_UI_soundOFF.png", this,NULL);

    bool isPaused = CCUserDefault::sharedUserDefault()->getBoolForKey("tinyBazooka_kSoundPausedKey");

    MenuItemToggle* soundToggleItem;
    if(isPaused == false) {
        soundToggleItem = MenuItemToggle::createWithTarget(this,menu_selector(OptionsMenu::SoundOnOff),
                          soundOnItem, soundOffItem,NULL);
    } else {
        soundToggleItem = MenuItemToggle::createWithTarget(this,menu_selector(OptionsMenu::SoundOnOff),
                          soundOffItem, soundOnItem,NULL);
    }

    soundToggleItem->setPosition(ccp(visibleSize.width* 0.5, visibleSize.height * 0.5 ));




    // create menu, it's an autorelease object
    Menu* pMenu = Menu::create(pmainMenuItem, presetItem,soundToggleItem, NULL);
    pMenu->setPosition(Vec2::ZERO);
    this->addChild(pMenu, 10);

    this->scheduleUpdate();

    return true;

}
开发者ID:Ratel13,项目名称:cc2dx33_wp8Game,代码行数:57,代码来源:OptionsMenuScene.cpp

示例5: addChild

Atlas6::Atlas6()
{
    auto s = Director::getInstance()->getWinSize();

    LabelBMFont* label = NULL;
    label = LabelBMFont::create("FaFeFiFoFu", "fonts/bitmapFontTest5.fnt");
    addChild(label);
    label->setPosition( Point(s.width/2, s.height/2+50) );
    label->setAnchorPoint( Point(0.5f, 0.5f) ) ;
    
    label = LabelBMFont::create("fafefifofu", "fonts/bitmapFontTest5.fnt");
    addChild(label);
    label->setPosition( Point(s.width/2, s.height/2) );
    label->setAnchorPoint( Point(0.5f, 0.5f) );

    label = LabelBMFont::create("aeiou", "fonts/bitmapFontTest5.fnt");
    addChild(label);
    label->setPosition( Point(s.width/2, s.height/2-50) );
    label->setAnchorPoint( Point(0.5f, 0.5f) ); 
}
开发者ID:ioyouj,项目名称:Hello-LWF-Cocos2d-x,代码行数:20,代码来源:LabelTest.cpp

示例6: updateBigBoomCount

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());
	}
}
开发者ID:DreamZL,项目名称:PlaneFight,代码行数:48,代码来源:LayerGameMain.cpp

示例7: showHighScoreLabel

//ハイスコアラベルの表示
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);
    }
    
}
开发者ID:mrt168,项目名称:nyanzame,代码行数:22,代码来源:GameScene.cpp

示例8: createWithNumber

BallSprite* BallSprite::createWithNumber(kBallNumber number)
{
    BallSprite *ballSprite = new BallSprite();
    ballSprite->setNumber(number);
    if(ballSprite && ballSprite->initWithFile(PNG_BALL))
    {
        //ボールの数字をラベルとして付ける
        const char* numberString = CCString::createWithFormat("%d", number)->getCString();
        LabelBMFont* numberLabel = CCLabelBMFont::create(numberString, FONT_NUMBER);
        numberLabel->setPosition(Point(ballSprite->getContentSize().width / 2,ballSprite->getContentSize().height / 2));
        numberLabel->setScale(1.8);
        ballSprite->addChild(numberLabel, kZOrderNumber, kTagNumber);
        
        //ボールのメモリを自動消去
        ballSprite->autorelease();
        
        //作ったSpriteを返す
        return ballSprite;
    } else {
        CC_SAFE_DELETE(ballSprite);
        return nullptr;
    }
}
开发者ID:kyorosuke,项目名称:cannesA,代码行数:23,代码来源:BallSprite.cpp


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