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


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

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


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

示例1:

ControlButton *TDDSubMenu::createButton(const std::string &name, int tag,
										  const Point &pos, const Size &size)
{
	Color3B colorNormal = Color3B::WHITE;
	//Color3B colorSelected = colorNormal;
	
	Scale9Sprite *bgButton = Scale9Sprite::create();
	Scale9Sprite *bgHiliButton = Scale9Sprite::create();
	
	// bgButton->setContentSize(Size(200, 50));
	Label *titleButton = Label::createWithSystemFont(name.c_str(), "Arial", 15);
	titleButton->setColor(colorNormal);
	
	
	ControlButton *button = ControlButton::create(titleButton, bgButton);
	button->setBackgroundSpriteForState(bgHiliButton, Control::State::HIGH_LIGHTED);

	TDDHelper::setAlphaPremultiplied(button);
	button->setTag(tag);
	button->setContentSize(size);
	button->setPosition(pos);
	button->setSelected(false);
	
	return button;
}
开发者ID:dwdcth,项目名称:SimpleTDD-cocos2dx,代码行数:25,代码来源:TDDSubMenu.cpp

示例2: init

bool LoginScene::init()
{
	if (!Layer::init())
		return false;
	Size winSize = Director::getInstance()->getWinSize();

	auto pBckSprite = Scale9Sprite::create("green_edit.png");
	addChild(pBckSprite);
	pBckSprite->setPosition(Vec2(winSize.width / 2, winSize.height / 2 + 25));
	pBckSprite->setContentSize(Size(winSize.width / 2, 35));

	m_txtUserName = ui::TextField::create(StringResUtil::instance()->getStringForKey("username"), "Arial",30);
	
	m_txtUserName->setPlaceHolderColor(Color4B::WHITE);
	m_txtUserName->setTextColor(Color4B::WHITE);
	addChild(m_txtUserName);
	m_txtUserName->setPosition(Vec2(winSize.width / 2, winSize.height / 2 + 25));

	auto pPwdBckSprite = Scale9Sprite::create("green_edit.png");
	addChild(pPwdBckSprite);
	pPwdBckSprite->setPosition(Vec2(winSize.width / 2, winSize.height / 2 - 25));
	pPwdBckSprite->setContentSize(Size(winSize.width / 2, 35));

	m_txtPassword = ui::TextField::create(StringResUtil::instance()->getStringForKey("password"), "Arial",30);
	m_txtPassword->setPlaceHolderColor(Color4B::WHITE);
	m_txtPassword->setTextColor(Color4B::WHITE);
	m_txtPassword->setPasswordEnabled(true);
	addChild(m_txtPassword);
	m_txtPassword->setPosition(Vec2(winSize.width / 2, winSize.height / 2 - 25));

	/*auto starMenuItem = MenuItemImage::create(
		"button.png",
		"button.png", CC_CALLBACK_1(LoginScene::starMenuCallback, this));
	starMenuItem->setPosition(Point::ZERO);
	starMenuItem->setContentSize(Size(80, 30));
	auto starMenu = Menu::create(starMenuItem, NULL);
	starMenu->setPosition(Point(winSize.width / 2, winSize.height / 2 - 80));
	this->addChild(starMenu, 1);*/

	LabelTTF *label = LabelTTF::create("login", "Marker Felt", 30);
	Scale9Sprite *normalBck = Scale9Sprite::create("button.png");
	ControlButton *button = ControlButton::create(label, normalBck);
	button->setContentSize(Size(80, 30));
	button->setPosition(Point(winSize.width / 2, winSize.height / 2 - 80));
	button->addTargetWithActionForControlEvents(this, cccontrol_selector(LoginScene::touchDown), Control::EventType::TOUCH_DOWN);
	addChild(button);
	return true;
}
开发者ID:yangyong3108,项目名称:project-001,代码行数:48,代码来源:LoginScene.cpp


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