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


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

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


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

示例1: init

// on "init" you need to initialize your instance
bool HelloWorld::init()
{
  if (!CCLayer::init()) {
    return false;
  }
  
  CCSize s = CCDirector::sharedDirector()->getWinSize();
  render_texture_ = CCRenderTexture::create(s.width, s.height,
                                            kCCTexture2DPixelFormat_RGBA8888);
  render_texture_->retain();
  render_texture_->setPosition(ccp(s.width / 2, s.height / 2));
  render_texture_->clear(1.0, 1.0, 1.0, 1.0);
  this->addChild(render_texture_);

  std::string text = "0123456789";
  for (int i = 0; i < 8; i++) {
    text += text;
  }
  CCLabelTTF* label = new CCLabelTTF;
  label->initWithString(text.c_str(), "Arial", 18,
                        CCSizeMake(1000, 0), kCCTextAlignmentLeft);
  label->setPosition(ccp(10, 760));
  label->setAnchorPoint(ccp(0, 1));
  label->setColor(ccc3(0, 0, 0));
  render_texture_->begin();
  label->visit();
  render_texture_->end();
  label->release();
  
  return true;
}
开发者ID:pfedor,项目名称:cocos2dx-bug,代码行数:32,代码来源:HelloWorldScene.cpp

示例2: CCLabelTTF

	CCLabelTTF * CCLabelTTF::labelWithString(const char *label, const char *fontName, float fontSize)
	{
		CCLabelTTF *pRet = new CCLabelTTF();
		if(pRet && pRet->initWithString(label, fontName, fontSize))
		{
			pRet->autorelease();
			return pRet;
		}
		CCX_SAFE_DELETE(pRet)
		return NULL;
	}
开发者ID:geniikw,项目名称:myFirst2DGame,代码行数:11,代码来源:CCLabelTTF.cpp

示例3: create

CCLabelTTF* CCLabelTTF::create(const char *string, const cocos2d::CCSize &dimensions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment, const char *fontName, float fontSize)
{
    CCLabelTTF *pRet = new CCLabelTTF();
    if(pRet && pRet->initWithString(string, dimensions, hAlignment, vAlignment, fontName, fontSize))
    {
        pRet->autorelease();
        return pRet;
    }
    CC_SAFE_DELETE(pRet);
    return NULL;
}
开发者ID:rossimrc,项目名称:AlbertEinstein,代码行数:11,代码来源:CCLabelTTF.cpp

示例4: CCLabelTTF

	CCLabelTTF * CCLabelTTF::labelWithString(const char *label, const CCSize& dimensions, CCTextAlignment alignment, const char *fontName, float fontSize)
	{
		CCLabelTTF *pRet = new CCLabelTTF();
		if(pRet && pRet->initWithString(label, dimensions, alignment, fontName, fontSize))
		{
			pRet->autorelease();
			return pRet;
		}
		CC_SAFE_DELETE(pRet);
		return NULL;
	}
开发者ID:tungt84,项目名称:cocos2d-blackberry,代码行数:11,代码来源:CCLabelTTF.cpp

示例5: init

bool MultiplayerLayer::init()
{
    bool bRet = false;
	do
	{
		CC_BREAK_IF(! OverlayBase::init());
		
		CCSize size = CCDirector::sharedDirector()->getWinSize();
		int leftSpace = 100;

        _opponentType = kHuman;
        
        CCMenuItemSprite* hItem = createMenuItemSprite((char*)"btnHotSeat128x128.png",
                                                       (char*)"btnHotSeatPressed.png",
                                                       menu_selector(MultiplayerLayer::onHotSeat));
        CCMenuItemSprite* onlineItem = createMenuItemSprite((char*)"btnOnlineGame128x128.png",
                                                       (char*)"btnOnlineGamePressed.png",
                                                       menu_selector(MultiplayerLayer::onOnlineGame));
        
        CCMenu* menu = CCMenu::create(hItem, onlineItem, NULL);
        menu->alignItemsVertically();
		menu->setPosition(ccp(leftSpace, size.height - 2 * leftSpace));
		addChild(menu, 1);
        
        
        if (!sgl_ConnectionManager.getRoomNumber().empty())
        {
            CCMenuItemSprite* onlineReconnectItem = createMenuItemSprite((char*)"btnOnlineGameReconnect.png",
                                                                (char*)"btnOnlineGamePressed.png",
                                                                menu_selector(MultiplayerLayer::onOnlineGame));
            
            menu->cocos2d::CCNode::addChild(onlineReconnectItem);
        }
        
		float menuLimit = hItem->getPosition().x + hItem->boundingBox().size.width + 20;

		CCLabelTTF* lH = new CCLabelTTF();
		lH->initWithString("Hot seat", S_F_TYPE.c_str(), 32);
		lH->setPosition(ccp(menuLimit, hItem->getPosition().y));
		lH->setAnchorPoint(ccp(0,0));
        hItem->addChild(lH);
        
        CCLabelTTF* lO = new CCLabelTTF();
        lO->initWithString("Random online game", S_F_TYPE.c_str(), 32);
        lO->setPosition(ccp(menuLimit, hItem->getPosition().y));
		lO->setAnchorPoint(ccp(0,0));
        onlineItem->addChild(lO);

        //Cancel - Go Menu
        CCMenuItemSprite* mRightArrow =
            sgl_SpriteFactory.createMenuItemSprite("btnArrow_Back128x128.png", "btnArrow_Back128x128Pressed.png", menu_selector(MultiplayerLayer::onQuit), this);
        CCMenu* menuReturn = CCMenu::create(mRightArrow, NULL);
        
        CCMenuItemSprite* mLeftArrow =
            sgl_SpriteFactory.createMenuItemSprite("btnArrow128x128.png", "btnArrow128x128Pressed.png", menu_selector(MultiplayerLayer::onConnect), this);
        
        CCMenu* mStartGame = CCMenu::create(mLeftArrow, NULL);
        
		menuReturn->setPosition(leftSpace, 150);
		mStartGame->setPosition(size.width - leftSpace - mLeftArrow->boundingBox().size.width * 0.5f, 150);
        
        addChild(mStartGame);
        addChild(menuReturn);
        
        
        _connectionStatus = CCLabelTTF::create("", S_F_TYPE.c_str(), 32);
		_connectionStatus->setPosition(ccp(size.width/2, 150));
        
        this->addChild(_connectionStatus);
        
		bRet = true;
	} while (0); 
    
	return bRet;
}
开发者ID:koboldul,项目名称:Football,代码行数:75,代码来源:MultiplayerLayer.cpp


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