예제 #1
0
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;
}
예제 #2
0
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;
}