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


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

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


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

示例1: SingleElementWidth

ScreenProgressBar::ScreenProgressBar()
	:_nodeBase(NULL), _layerFrame(NULL), _layerProgressBar(NULL), _controller(NULL)
{
	
	{
		CCSize size;
		size.width = SingleElementWidth();
		size.height = CCDirector::sharedDirector()->getWinSize().height;
		setContentSize(size);
	}

	{
		CCLayerColor* layerN = CCLayerColor::create(normalColor(), SingleElementWidth(), 30);
		CCLabelTTF *label = CCLabelTTF::create("Loading. Please stand by.", MAX_DEFAULT_FONT, 10);
		label->setTag(BUTTON_LABEL_TAG);
		label->setColor(MAX_COLOR_WHITE);
		CCSize sz = layerN->getContentSize();
		sz.height /= 2;
		label->setPosition(ccp((int)(sz.width * 0.25), (int)(sz.height * 0.25)));
		sz.width *= CCDirector::sharedDirector()->getContentScaleFactor();
		sz.height *= CCDirector::sharedDirector()->getContentScaleFactor();
		label->setContentSize(sz);
		label->setAnchorPoint(ccp(0, 0));
		layerN->addChild(label);
		CocosHelper::MoveNode(layerN->getChildByTag(11), ccp(15, 5));
	
		addChild(layerN);
		_buttons->addObject(layerN);
	}


	if (!_nodeBase)
	{
		_nodeBase = CCNode::create();
		_nodeBase->setContentSize(CCSizeMake(SingleElementWidth(), SingleElementHeight()));
		_nodeBase->setAnchorPoint(ccp(0, 0));
		_nodeBase->setPosition(ccp(0, 0));
		addChild(_nodeBase);
		_buttons->addObject(_nodeBase);
	}


	ccColor4B color;
	
	color = normalColor();
	if (!_layerFrame)
	{
		_layerFrame = CCLayerColor::create(color, SingleElementWidth(), 50);
		_layerFrame->setAnchorPoint(ccp(0, 0));
		_layerFrame->setPosition(ccp(0, 0));
		_nodeBase->addChild(_layerFrame);
	}


	color = selectedColor();
	if (!_layerProgressBar)
	{
		_layerProgressBar = CCLayerColor::create(color, 0, 50);
		_layerProgressBar->setAnchorPoint(ccp(0, 0));
		_layerProgressBar->setPosition(ccp(0, 0));
		_nodeBase->addChild(_layerProgressBar);
	}

	SetProgress(0.0);
}
开发者ID:KatekovAnton,项目名称:MAXNew,代码行数:65,代码来源:ScreenProgressBar.cpp

示例2: init

bool CCLobbyView::init( CCNetworkLogic* network, const CCSize& mySize )
{
    if( CCLayer::init() )
    {
        CCSize winSize = CCDirector::sharedDirector()->getWinSize();
        const CCPoint& center = ccpMult( ccpFromSize( mySize ), 0.5f );
        CCPoint position = CCPointZero;
        CCSize size = CCSizeZero;
        int length = 0;
        int fontSize = 0;
        
        this->setNetwork( network );
        
        CCSprite* s = CCSprite::create("Images/r1.png");
        s->retain();
        CCRect rect = CCRectZero;
        rect.size = s->getContentSize();
        s->release();
        
        fontSize = 12;
        CCLabelTTF* label = CCLabelTTF::create( "Connect", "fonts/American Typewriter.ttf", fontSize );
        label->setColor( ccc3( 0, 0, 0 ) );
        CCScale9Sprite* sprite = CCScale9Sprite::create("Images/r1.png", rect, rect );
        sprite->setScaleX( 1.4f );
        sprite->setScaleY( 0.8f );
        CCControlButton* button = CCControlButton::create( label, sprite );
        button->addTargetWithActionForControlEvents( this, cccontrol_selector( CCLobbyView::connectButtonCallback ), CCControlEventTouchUpInside);
        button->setPreferredSize( rect.size );
        position = center;
        position.y -= 136;
        position.x -= 100;
        button->setPosition( position );
        this->setConnectButton( button );
        
        label = CCLabelTTF::create( "Create Room", "fonts/American Typewriter.ttf", fontSize );
        label->setColor( ccc3( 0, 0, 0 ) );
        sprite = CCScale9Sprite::create("Images/r1.png", rect, rect );
        sprite->setScaleX( 1.4f );
        sprite->setScaleY( 0.8f );
        button = CCControlButton::create( label, sprite );
        button->addTargetWithActionForControlEvents( this, cccontrol_selector( CCLobbyView::createGameButtonCallback ), CCControlEventTouchUpInside);
        button->setPreferredSize( rect.size );
        position = center;
        position.y -= 136;
        //position.x += 0;
        button->setPosition( position );
        this->setCreateGameButton( button );
        
        label = CCLabelTTF::create( "Random Room", "fonts/American Typewriter.ttf", fontSize );
        label->setColor( ccc3( 0, 0, 0 ) );
        sprite = CCScale9Sprite::create("Images/r1.png", rect, rect );
        sprite->setScaleX( 1.6f );
        sprite->setScaleY( 0.8f );
        button = CCControlButton::create( label, sprite );
        button->addTargetWithActionForControlEvents( this, cccontrol_selector( CCLobbyView::joinGameButtonCallback ), CCControlEventTouchUpInside);
        button->setPreferredSize( rect.size );
        position = center;
        position.y -= 136;
        position.x += 100;
        button->setPosition( position );
        this->setRandomGameButton( button );
        
        this->_lobbyViewDataSource = new CCLobbyViewDataSource( this );

        fontSize = 16;
        length = mySize.width;
        size = this->_lobbyViewDataSource->cellSizeForTable( NULL );
        size.height *= 3;
        CCTableView* table = CCTableView::create( this->_lobbyViewDataSource, size );
        table->setContentOffset( CCPointZero );
        table->setDirection(kCCScrollViewDirectionVertical);
        position = center;
        position.x -= size.width * 0.5f;
        position.y -= fontSize + ( size.height * 0.17f );
        table->setPosition( position );
        table->setDelegate( this );
        table->setVerticalFillOrder(kCCTableViewFillTopDown);
        this->setRoomTable( table );
        table->reloadData();
        
        fontSize = 16;
        label = CCLabelTTF::create("Running games:", "fonts/American Typewriter.ttf", fontSize,
                                                 winSize, kCCTextAlignmentCenter, kCCVerticalTextAlignmentCenter);
        position = center;
        position.x -= size.width * 0.4f;
        position.y += size.height - ( fontSize * 0.5f );
        label->setPosition( position );
        //label->setAnchorPoint( CCPointZero );
        this->setRoomTableLabel( label );
        
        fontSize = 16;
        CCLabelTTF* console = CCLabelTTF::create("disconnected", "fonts/American Typewriter.ttf", fontSize,
                                             winSize, kCCTextAlignmentCenter, kCCVerticalTextAlignmentCenter);
        
            
        console->setColor( ccc3(255, 255, 255) );
        console->setContentSize(winSize);
        position = center;
        position.y += 100;
        console->setPosition( position );
//.........这里部分代码省略.........
开发者ID:darkcl,项目名称:Cocos2d-x_Photon_MultiPlatform_Test,代码行数:101,代码来源:CCLobbyView.cpp


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