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


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

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


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

示例1:

bool T05CCLabelTTf::init()
{
	if (!BaseLayer::init())
		return false;

	CCSize winSize = CCDirector::sharedDirector()->getWinSize();

	/*
		提供了三个类来显示文字
		CCLabelTTf,CCLabelAtlas,CCLabelIBMFont
	*/
	CCLabelTTF* pLabelTTf = CCLabelTTF::create("Hello,World", "Arial", 30);
	addChild(pLabelTTf);
	pLabelTTf->setPosition(ccp(winSize.width / 2, winSize.height / 2));

	setTouchEnabled(true);
	setTouchMode(kCCTouchesOneByOne);

	return true;
}
开发者ID:dfwxb,项目名称:cocos_lesson2,代码行数:20,代码来源:T05CCLabelTTf.cpp

示例2: CCLog

bool Recipe15::init()
{
    if ( !RecipeBase::init() )
    {
        return false;
    }
    
    CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
    
    int fontSize = CCEGLView::sharedOpenGLView()->getDesignResolutionSize().height/320.0f * 16;
    std::string text = "CCCallFuncを使用して呼び出されたメソッドにより、\nログ出力されます。";
    CCLabelTTF *label = CCLabelTTF::create(text.c_str(), "Helvetica", fontSize);
    label->setPosition(ccp(visibleSize.width/2, visibleSize.height/2));
    this->addChild(label);
    
    CCLog("--- Recipe 15 ------");
    this->method1();
    
    return true;
}
开发者ID:DPigpen,项目名称:cocos2dx_recipe,代码行数:20,代码来源:Recipe15.cpp

示例3: init

bool TitleNode::init() {
    if( !iNode::init() )
        return false;
    
    CCSize designResoulutionSize = CCEGLView::sharedOpenGLView()->getDesignResolutionSize();
    
    CCSize labelDimension = CCSizeMake(300, 200);
    CCLabelTTF* sceneDebugLabel = CCLabelTTF::create("Let's\nThree Match!", "Arial", 30, labelDimension, kCCTextAlignmentCenter);
    sceneDebugLabel->setAnchorPoint(ccp(0.5f, 1));
    sceneDebugLabel->setPosition(ccp(designResoulutionSize.width/2, designResoulutionSize.height/2+100));
    sceneDebugLabel->setColor(ccRED);
    this->addChild(sceneDebugLabel);
    
    ProgressControl* progress = ProgressControl::create("UI/gauge_bg.png", "UI/gauge_content.png", NULL, this, callfuncO_selector(TitleNode::onProgressEnded), CommonEnum::eProgressToRight);
    progress->setPosition(ccp((designResoulutionSize.width-progress->boundingBox().size.width)/2, 100));
    progress->setValue(1.0f);
    this->addChild(progress);
    
    return true;
}
开发者ID:GoodMorningCody,项目名称:ThreeMatchPuzzleX,代码行数:20,代码来源:TitleNode.cpp

示例4: showGametimeLabel

void GameScene::showGametimeLabel()
{
    const int tagGametimeLabel = 100;
    
    CCString* timeString = CCString::createWithFormat("%8.1fs", gametime);
    
    CCLabelTTF* timerLabel = (CCLabelTTF*)this->getChildByTag(tagGametimeLabel);
    if (timerLabel) {
        timerLabel->setString(timeString->getCString());
    }
    else
    {
        CCSize winSize = CCDirector::sharedDirector()->getWinSize();
        
        timerLabel = CCLabelTTF::create(timeString->getCString(), "Arial", 24.0);
        timerLabel->setPosition(ccp(winSize.width*0.9, winSize.height*0.9));
        timerLabel->setTag(tagGametimeLabel);
        this->addChild(timerLabel);
    }
}
开发者ID:Yarimizu14,项目名称:nyan25,代码行数:20,代码来源:GameScene.cpp

示例5: ccTouchBegan

bool HelloWorld::ccTouchBegan(CCTouch *touch, CCEvent *event)
{
    CCPoint touchLocation = touch->getLocation();
    
    char posString [50];
    sprintf (posString, "%0.1f - %0.1f", touchLocation.x, touchLocation.y);
    CCLabelTTF *label = (CCLabelTTF *)this->getChildByTag(999);
    label->setPosition(touchLocation);
    
    if (GeometryUtil::pointInRegion(touchLocation, region)) {
        label->setColor(ccGREEN);
    }
    else {
        label->setColor(ccRED);
    }
    
    label->setString(posString);
    
	return true;
}
开发者ID:irontec,项目名称:PointInRegion,代码行数:20,代码来源:HelloWorldScene.cpp

示例6: init

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

  CCSize windowSize = CCDirector::sharedDirector()->getWinSize();

  CCLabelTTF* pLabel = CCLabelTTF::create("Hello cocos2d-x!", "Thonburi", 48);
  pLabel->setPosition(ccp(windowSize.width / 2, windowSize.height - 36));
  this->addChild(pLabel);

  CCSprite *spaceCargoShip = CCSprite::create("SpaceCargoShip.png");
  spaceCargoShip->setPosition(ccp(windowSize.width/2, windowSize.height/2));
  this->addChild(spaceCargoShip);

  CCMoveTo *movement = CCMoveTo::create(5.0, ccp(0, windowSize.height/2));
  spaceCargoShip->runAction(movement);
  
  return true;
}
开发者ID:hslim,项目名称:learning-cocos2dx,代码行数:21,代码来源:HelloWorldScene.cpp

示例7: onEnter

void TouchesMainScene::onEnter()
{
    PerformBasicLayer::onEnter();

    CCSize s = CCDirector::sharedDirector()->getWinSize();

    // add title
    CCLabelTTF *label = CCLabelTTF::create(title().c_str(), "Arial", 32);
    addChild(label, 1);
    label->setPosition(ccp(s.width/2, s.height-50));

    scheduleUpdate();

    m_plabel = CCLabelBMFont::create("00.0", "fonts/arial16.fnt");
    m_plabel->setPosition(ccp(s.width/2, s.height/2));
    addChild(m_plabel);

    elapsedTime = 0;
    numberOfTouchesB = numberOfTouchesM = numberOfTouchesE = numberOfTouchesC = 0;    
}
开发者ID:GhostSoar,项目名称:Cocos2dWindows,代码行数:20,代码来源:PerformanceTouchesTest.cpp

示例8: showStartInfo

void MainGameScene::showStartInfo()
{
    CCSize winSize = CCDirector::sharedDirector()->getWinSize();
    
    CCMenuItemImage* pStartItem;
    pStartItem = CCMenuItemImage::create("logo_Info2.png", "logo_Info2.png",this,menu_selector(MainGameScene::startGame));
    pStartItem->setPosition(ccp(winSize.width * 0.5, winSize.height * 0.5));
    pStartItem->setScale(0.7);
     CCSize pStartItemSize = pStartItem->getContentSize();
    
    CCLabelTTF* startLabel1;
    startLabel1 = CCLabelTTF::create("Let's Arrows", "Copperplate", 60.0);
    startLabel1->setColor(ccc3(0, 0, 0));
    startLabel1->setPosition(ccp(pStartItemSize.width * 0.5 ,pStartItemSize.height * 0.7));
    pStartItem->addChild(startLabel1);
    
    CCString* levelStr = CCString::createWithFormat("Lv:%d",m_level);
    CCLabelTTF* levelLabel;
    levelLabel = CCLabelTTF::create(levelStr->getCString(), "Copperplate", 60.0);
    levelLabel->setColor(ccc3(0, 0, 0));
    levelLabel->setPosition(ccp(pStartItemSize.width * 0.5 ,pStartItemSize.height * 0.5));
    pStartItem->addChild(levelLabel);


    
    CCString* minCountString = CCString::createWithFormat("MIN  %d  TOUCH",minimamCount);
    CCLabelTTF* startLabel2;
    startLabel2 = CCLabelTTF::create(minCountString->getCString(), "Copperplate", 50.0);
    startLabel2->setColor(ccc3(0, 0, 0));
    startLabel2->setPosition(ccp(pStartItemSize.width * 0.5 ,pStartItemSize.height * 0.2));
    pStartItem->addChild(startLabel2);
    
    
    CCMenu* pMenu = CCMenu::create(pStartItem,NULL);
    pMenu->setPosition(CCPointZero);
    pMenu->setTag(tagStartInfo);
    
    this->addChild(pMenu);

    
}
开发者ID:k-tetsuhiro,项目名称:app02,代码行数:41,代码来源:MainGameScene.cpp

示例9: init

bool TitleLayer::init()
{
	if ( !CCLayer::init() )
	{
		return false;
	}
    
    // Get window size
    CCSize windowSize = CCDirector::sharedDirector()->getWinSize();
    
    // Create text label for title of game - "@stroids" - don't sue me Atari!
    CCLabelTTF *title = CCLabelTTF::labelWithString("@stroids", "Courier", 64.0);
    
    // Position title at center of screen
    title->setPosition(ccp(windowSize.width / 2, windowSize.height/2));
    
    // Add to layer
    this->addChild(title, 1);
    
    // Set the default CCMenuItemFont font
    CCMenuItemFont::setFontName("Courier");
    
    // Create "play," "scores," and "controls" buttons - when tapped, they call methods we define: playButtonAction and scoresButtonAction
    CCMenuItemFont *playButton = CCMenuItemFont::itemFromString("play", this, menu_selector(TitleLayer::playButtonAction));
    CCMenuItemFont *scoresButton = CCMenuItemFont::itemFromString("scores", this, menu_selector(TitleLayer::scoresButtonAction));
    CCMenuItemFont *controlsButton = CCMenuItemFont::itemFromString("controls", this, menu_selector(TitleLayer::controlsButtonAction));
    
    // Create menu that contains our buttons
    CCMenu *menu = CCMenu::menuWithItems(playButton, scoresButton, controlsButton, NULL);

    // Align buttons horizontally
    menu->alignItemsHorizontallyWithPadding(20);
    
    // Set position of menu to be below the title text
    menu->setPosition(ccp(windowSize.width / 2, title->getPosition().y - title->getContentSize().height / 1.5));

    // Add menu to layer
    this->addChild(menu, 2);
        
	return true;
}
开发者ID:Hyacinth,项目名称:AsteroidsCocos2D-x,代码行数:41,代码来源:TitleLayer.cpp

示例10: createContentAtIndex

BaseLayer* MainLayerZhuangBeiBody::createContentAtIndex(unsigned int index)
{
	MainLayerZhuangBeiBaseBody* ret = NULL;
	if (index >= sizeof(itemFiles)/sizeof(string))
	{
		//CCLog("MainLayerZhuangBeiBody::createContentAtIndex --> index >= [%d] (sizeof(itemFiles)/sizeof(string))",sizeof(itemFiles)/sizeof(string));
		return ret;
	}
	switch (index)
	{
	case 0://
		ret = new MainLayerZhuangBeiAllBody(Type_WuQi);
		ret->autorelease();
		break;
	case 1://
		ret = new MainLayerZhuangBeiAllBody(Type_FangJu);
		ret->autorelease();
		break;
	case 2://
		ret = new MainLayerZhuangBeiAllBody(Type_ShiPin);
		ret->autorelease();
		break;
	case 3://全部
		ret = new MainLayerZhuangBeiAllBody(Type_All);
		ret->autorelease();
		break;
	default:
		ret = new MainLayerZhuangBeiBaseBody(From_ZhuangBeiList);
		ret->autorelease();

		CCLabelTTF *label = CCLabelTTF::create("Zhuang Bei Not implement!", "Helvetica", 40.0);
		label->setPosition(ccp(mWinSize.width/2,mWinSize.height/2));
		ret->addChild(label);
		break;
	}

	ret->setFooter(mFooterLayer);
	ret->setTableViewPos(ccp(8,74));

	return ret;
}
开发者ID:longguai,项目名称:game-DarkWar,代码行数:41,代码来源:MainLayerZhuangBeiBody.cpp

示例11: initBtCreditos

void Ajustes::initBtCreditos(){
    btCreditos = MenuItemImage::create("ajustes_btCreditos.png", "ajustes_btCreditos_down.png", callfunc_selector(Ajustes::irCreditos));
    btCreditos->setScale(escalaAncha);
    btCreditos->setAnchorPoint(Vec2(0,0));
    btCreditos->setPosition(espacioSuperiorBtAtras*escala,visibleSize.height/2);
    
    menuCreditos = Menu::create(btCreditos, NULL);
    menuCreditos->setPosition(Vec2::ZERO);
    botonAtras->setZOrder(10);
    menuCreditos->retain();
    this->addChild(menuCreditos, 1);
    
    //btCreditosTexto
    CCLabelTTF *lbBtCreditos = CCLabelTTF::create(LanguageManager::getInstance()->getString("AjustesBtCreditos"), "HVD_Comic_Serif_Pro.ttf", 70,Size(btCreditos->getContentSize().width, 120), TextHAlignment::CENTER);
    lbBtCreditos->setColor(Color3B(255,255,255));
    lbBtCreditos->setVerticalAlignment(TextVAlignment::CENTER);
    lbBtCreditos->setAnchorPoint(Vec2(0.5,0));
    lbBtCreditos->setPosition(btCreditos->getContentSize().width/2,0);
    btCreditos->addChild(lbBtCreditos, 1);
    
}
开发者ID:si2info,项目名称:info.si2.mostrosity,代码行数:21,代码来源:Ajustes.cpp

示例12: init

bool WinScene::init() {
	bool bRet = false;

	do {
		CC_BREAK_IF(! CCLayer::init());

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

		/* 添加一个标签 */
		CCLabelTTF* winLab = CCLabelTTF::create("You Win!", PATH_FONT_PUBLIC, GlobalParam::PublicFontSizeLarge);
		winLab->setPosition(ccp(visibleSize.width / 2, visibleSize.height - 100));
		this->addChild(winLab);

		/* 3秒后返回关卡选择场景 */
		this->schedule(schedule_selector(WinScene::backToTollgateSelectScene), 3.0f);

		bRet = true;
	} while (0);

	return bRet;
}
开发者ID:ruozigongzuoshi,项目名称:goddessemblem,代码行数:21,代码来源:WinScene.cpp

示例13: setTouchEnabled

HelloWorld::HelloWorld()
{
   setTouchEnabled( true );
   setAccelerometerEnabled( true );
   
   CCSize s = CCDirector::sharedDirector()->getWinSize();
   // init physics
   this->initPhysics();
   
   CCSpriteBatchNode *parent = CCSpriteBatchNode::create("blocks.png", 100);
   m_pSpriteTexture = parent->getTexture();
   
   addChild(parent, 0, kTagParentNode);
   
   CCLabelTTF *label = CCLabelTTF::create("Tap screen", "Marker Felt", 32);
   addChild(label, 0);
   label->setColor(ccc3(0,0,255));
   label->setPosition(ccp( s.width/2, s.height-50));
   
   scheduleUpdate();
}
开发者ID:NonlinearIdeas,项目名称:RopeTest,代码行数:21,代码来源:HelloWorldScene.cpp

示例14: init

bool RobotLooseLayer::init()
{
    CCSize mapSize = GameParams::getInstanse()->mapSize();
    
    if ( !initWithColor(ccc4(145,145,145,255 * 0.45f)) )
    {
        return false;
    }
    
    CCLabelTTF *label = CCLabelTTF::create(CCLocalizedString("RobotBroken", "NotLocalized"), "Marker Felt", 42);
    
    label->setAnchorPoint( CCPointZero );
    label->setPosition( CCPointZero );
    
    addChild(label, 20);
    
    setContentSize(CCSizeMake(label->getContentSize().width, label->getContentSize().height));
    setPosition(ccp(mapSize.width / 2 - getContentSize().width / 2, -getContentSize().height));
    
    return true;
}
开发者ID:misty-fungus,项目名称:piktomir,代码行数:21,代码来源:RobotLooseLayer.cpp

示例15: tableCellAtIndex

CCTableViewCell* EXMainMenuScene::tableCellAtIndex(CCTableView *table, unsigned int idx)
{
    CCString *string = (CCString*)m_listData->objectAtIndex(idx);
    CCTableViewCell *cell = table->dequeueCell();
    if (!cell) {
        cell = new CCTableViewCell();
        cell->autorelease();
        CCLabelTTF *label = CCLabelTTF::create(string->getCString(), "Helvetica", 20.0);
        label->setPosition(ccp(m_winSize.width * .5, 30));
        label->setTag(123);
        cell->addChild(label);
    }
    else
    {
        CCLabelTTF *label = (CCLabelTTF*)cell->getChildByTag(123);
        label->setString(string->getCString());
    }
    
    
    return cell;
}
开发者ID:grefZhou,项目名称:cocos2dx-extensions-master,代码行数:21,代码来源:EXMainMenuScene.cpp


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