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


C++ LinearLayoutParameter::setWidth方法代码示例

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


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

示例1: init

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

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

	/////////////////////////////
	// 2. add a menu item with "X" image, which is clicked to quit the program
	//    you may modify it.

	// add a "close" icon to exit the progress. it's an autorelease object
	CCMenuItemImage* pCloseItem = CCMenuItemImage::create (
									  "CloseNormal.png",
									  "CloseSelected.png",
									  this,
									  menu_selector ( HelloWorld::menuCloseCallback ) );

	pCloseItem->setPosition ( ccp ( origin.x + visibleSize.width -
									pCloseItem->getContentSize().width / 2 ,
									origin.y + pCloseItem->getContentSize().height / 2 ) );

	// create menu, it's an autorelease object
	CCMenu* pMenu = CCMenu::create ( pCloseItem, NULL );
	pMenu->setPosition ( CCPointZero );
	this->addChild ( pMenu, 1 );

	/////////////////////////////
	// 3. add your codes below...

	// add a label shows "Hello World"
	// create and initialize a label

	CCLabelTTF* pLabel = CCLabelTTF::create ( "Hello World", "Arial", 26 );

	// position the label on the center of the screen
	pLabel->setPosition ( ccp ( origin.x + visibleSize.width / 2,
								origin.y + visibleSize.height - pLabel->getContentSize().height ) );

	// add the label as a child to this layer
	this->addChild ( pLabel, 1 );

	// add "HelloWorld" splash screen"
	CCSprite* pSprite = CCSprite::create ( "HelloWorld.png" );

	// position the sprite on the center of the screen
	pSprite->setPosition ( ccp ( visibleSize.width / 2 + origin.x,
								 visibleSize.height / 2 + origin.y ) );

	// add the sprite as a child to this layer
	this->addChild ( pSprite, 0 );

	GKoala::LayoutFactory factory;

	LayoutInterface* pLayout = factory.createLinearLayout();

	CCNode* pNode = CCNode::create();
	{
		LinearLayoutParameter* pParameter = LinearLayoutParameter::createWrapWrap();
		pParameter->setWidth ( SP::sp ( 22 ) )->setHeight ( SP::psh ( 0.5F ) );

		pLayout->addChildWith ( pNode, pParameter );
	}

	addChild ( pLayout );

	return true;
}
开发者ID:gelldur,项目名称:GKoala,代码行数:74,代码来源:HelloWorldScene.cpp


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