本文整理汇总了C++中UIButton类的典型用法代码示例。如果您正苦于以下问题:C++ UIButton类的具体用法?C++ UIButton怎么用?C++ UIButton使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UIButton类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: processGuildChat
void TaskChatLayer::processGuildChat(int type, bool visible)
{
UIButton* btnLeft = taskChatLayout->FindChildObjectByName<UIButton>("ItemExchangShopBtn");
UILabel* labelLeft = taskChatLayout->FindChildObjectByName<UILabel>("ItemExchangText");
btnLeft->setVisible(visible);
labelLeft->setVisible(visible);
// type 10 11 12 13 分别代表公会商人、祈福、活动、排行
if(type == 10)
{
labelLeft->setString(Localizatioin::getLocalization("G_SHOP_TITLE"));
}
else if(type == 11)
{
labelLeft->setString(Localizatioin::getLocalization("G_BENEDICTION_TITLE"));
}
else if(type == 12)
{
labelLeft->setString(Localizatioin::getLocalization("G_INSTANCE"));
}
else if(type == 13)
{
labelLeft->setString(Localizatioin::getLocalization("G_RANK"));
}
mShopType = type;
}
开发者ID:JamShan,项目名称:xcode_jifengyongzhezhuan,代码行数:26,代码来源:TaskChatLayer.cpp
示例2: UIControl
FogControl::FogControl(const Rect & rect, FogControlDelegate *newDelegate)
: UIControl(rect)
{
ControlsFactory::CustomizeDialog(this);
delegate = newDelegate;
Rect propertyRect(0, 0, rect.dx, rect.dy - ControlsFactory::BUTTON_HEIGHT);
fogProperties = new PropertyList(propertyRect, NULL);
AddControl(fogProperties);
ControlsFactory::AddFogSubsection(fogProperties, true, 0.006f, Color::White());
Rect buttonRect(0, rect.dy - ControlsFactory::BUTTON_HEIGHT, rect.dx / 2, ControlsFactory::BUTTON_HEIGHT);
UIButton *btnCancel = ControlsFactory::CreateButton(buttonRect, LocalizedString(L"dialog.cancel"));
btnCancel->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &FogControl::OnCancel));
AddControl(btnCancel);
SafeRelease(btnCancel);
buttonRect.x = rect.dx - buttonRect.dx;
UIButton *btnCreate = ControlsFactory::CreateButton(buttonRect, LocalizedString(L"dialog.set"));
btnCreate->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &FogControl::OnSet));
AddControl(btnCreate);
SafeRelease(btnCreate);
}
开发者ID:abaradulkin,项目名称:dava.framework,代码行数:26,代码来源:FogControl.cpp
示例3: buttonClicked
void PromptBox::buttonClicked(CCObject *pSender, TouchEventType eType)
{
if (eType != TOUCH_EVENT_ENDED)
{
return;
}
::playSound("music/click.ogg");
UIButton *button = dynamic_cast<UIButton*>(pSender) ;
int tag = button->getTag() ;
switch (tag)
{
case ButtonTag_Cancel:
{
removeFromParent();
}
break;
case ButtonTag_Confirm:
{
CCDirector::sharedDirector()->end();
}
break;
default:
break;
}
}
开发者ID:joyfish,项目名称:Zombie,代码行数:32,代码来源:PromptBox.cpp
示例4: UIButton
NS_CC_BEGIN
/**
* 创建
*/
UIButton* UIButton::create(const char *upSprite,const char *downSprite)
{
UIButton *node = new UIButton();
if (node)
{
node->_up = CCSprite::create(upSprite);
node->_down = CCSprite::create(downSprite);
node->upPngName = upSprite;
node->downPngName = downSprite;
if (node->_up && node->_down)
{
node->addChild(node->_up);
node->addChild(node->_down );
node->_up->setVisible(true);
node->_down->setVisible(false);
node->autorelease();
return node;
}
}
CC_SAFE_DELETE(node);
return NULL;
}
开发者ID:coderHsc,项目名称:sygame,代码行数:26,代码来源:UIButton.cpp
示例5: addChild
void GameWeekRewardLayer::BindingUIItems(CCObject *p)
{
CCString str;
str.initWithFormat("%d%d",eNetMsgTypeMissionSys, eNetMsgMissionSysWeekRewardKind);
CSJson::Value root = XQDate::sharedInstance().GetDate(str.getCString());
bool isShowBtn = false;
for (int i = 0; i < root.size(); i ++) {
CSJson::Value & val = root[i];
if (val["iscomplete"].asInt() == 1) {
isShowBtn = true;
}
}
ul = UILayer::create();
addChild(ul, 1);
auto myLayout = static_cast<Layout*>(GUIReader::shareReader() -> widgetFromJsonFile("./CocoStudioResources/WeekRewardLayer.json"));
ul -> addWidget(myLayout);
UIPanel *myPanel = dynamic_cast<UIPanel*>(ul -> getWidgetByName("Panel_2"));
myPanel -> addReleaseEvent(this, coco_releaseselector(GameWeekRewardLayer::touchWindow));
// bind ui images
UIButton *btn = dynamic_cast<UIButton*>(ul -> getWidgetByName("LotteryBtn"));
if (isShowBtn) {
btn->disable();
btn->setVisible(false);
}
else {
btn -> addReleaseEvent(this, coco_releaseselector(GameWeekRewardLayer::getWeekRewardBtnClick));
}
//设置字体不被选中;
}
开发者ID:anzhongliu,项目名称:SmallGame_Cocos2dx,代码行数:35,代码来源:GameWeekRewardLayer.cpp
示例6: InitializeControl
// Initialize the control(s) attached.
void UIButtonMetadata::InitializeControl(const String& controlName, const Vector2& position)
{
BaseMetadata::InitializeControl(controlName, position);
int paramsCount = this->GetParamsCount();
for (BaseMetadataParams::METADATAPARAMID i = 0; i < paramsCount; i ++)
{
UIButton* button = dynamic_cast<UIButton*>(this->treeNodeParams[i].GetUIControl());
WideString controlText = StringToWString(button->GetName());
HierarchyTreeNode* activeNode = GetTreeNode(i);
// Initialize the button for all states.
int statesCount = UIControlStateHelper::GetUIControlStatesCount();
for (int stateID = 0; stateID < statesCount; stateID ++)
{
UIControl::eControlState state = UIControlStateHelper::GetUIControlState(stateID);
button->SetStateFont(state, EditorFontManager::Instance()->GetDefaultFont());
button->SetStateText(state, controlText);
// Button is state-aware.
activeNode->GetExtraData().SetLocalizationKey(controlText, state);
}
// Define some properties for the reference state.
button->SetStateDrawType(GetReferenceState(), UIControlBackground::DRAW_SCALE_TO_RECT);
}
}
开发者ID:dima-belsky,项目名称:dava.framework,代码行数:29,代码来源:UIButtonMetadata.cpp
示例7: addChild
void CocosGUIExamplesRegisterScene::onEnter()
{
CCScene::onEnter();
m_pUILayer = UILayer::create();
m_pUILayer->scheduleUpdate();
addChild(m_pUILayer);
// register root from json
m_pLayout = dynamic_cast<UILayout*>(GUIReader::shareReader()->widgetFromJsonFile("cocosgui/gui_examples/register_1/register_1.json"));
m_pUILayer->addWidget(m_pLayout);
// e-mail layout
UILayout* eMail_layout = dynamic_cast<UILayout*>(m_pLayout->getChildByName("e-mail_Panel"));
// ui node container add to e-mail layout
UINodeContainer* nodeContainer = UINodeContainer::create();
nodeContainer->setPosition(ccp(eMail_layout->getContentSize().width / 2, eMail_layout->getContentSize().height / 2));
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) && (CC_TARGET_PLATFORM != CC_PLATFORM_WP8)
// CCEditBox add to ui node container
CCSize editBoxSize = eMail_layout->getContentSize();
CCEditBox* email_editBox = CCEditBox::create(editBoxSize, CCScale9Sprite::create("cocosgui/gui_examples/register_1/e-mail.png"));
email_editBox->setFontName("SongTypeFont");
email_editBox->setFontSize(20);
email_editBox->setPlaceholderFontColor(ccc3(127, 127, 127));
email_editBox->setPlaceHolder("Email");
email_editBox->setInputMode(kEditBoxInputModeEmailAddr);
nodeContainer->addCCNode(email_editBox);
// add ui node container to layout
eMail_layout->addChild(nodeContainer);
#else
#pragma message ("Warning: CCEditBox not implmented for CC_PLATFORM_WINRT and CC_PLATFORM_WP8")
#endif
// content panel
UILayout* content_panel = dynamic_cast<UILayout*>(m_pLayout->getChildByName("content_Panel"));
// password textfield add event
UITextField* passwordAgin_textfield = dynamic_cast<UITextField*>(content_panel->getChildByName("password agin_TextField"));
passwordAgin_textfield->addAttachWithIMEEvent(this, coco_TextField_AttachWithIME_selector(CocosGUIExamplesRegisterScene::attachWithIMEEvent));
passwordAgin_textfield->addDetachWithIMEEvent(this, coco_TextField_DetachWithIME_selector(CocosGUIExamplesRegisterScene::detachWithIMEEvent));
// register button
UILayout* register_button_panel = dynamic_cast<UILayout*>(m_pLayout->getChildByName("register button_Panel"));
UIButton* button = dynamic_cast<UIButton*>(register_button_panel->getChildByName("register_Button"));
button->addReleaseEvent(this, coco_releaseselector(CocosGUIExamplesRegisterScene::toCocosGUIExamplesEquipScene));
// back button
UIButton* back_button = UIButton::create();
back_button->setTouchEnable(true);
back_button->loadTextures("cocosgui/UITest/b1.png", "cocosgui/UITest/b2.png", "");
back_button->setPosition(ccp(back_button->getContentSize().width, back_button->getContentSize().height));
back_button->addReleaseEvent(this, coco_releaseselector(CocosGUIExamplesRegisterScene::toCocosGUIScene));
// back_button->addReleaseEvent(this, coco_releaseselector(CocosGUIExamplesRegisterScene::toCocosGUIExamplesStartScene));
m_pUILayer->addWidget(back_button);
}
开发者ID:2uemg8sq98r3,项目名称:cocos2d-x,代码行数:60,代码来源:CocosGUIExamplesRegisterScene.cpp
示例8: SetActiveTableFrame
//----------------------------------------------------------------------------
void UIAuiManager::SetActiveTableFrame(const std::string &tabName)
{
std::map<std::string, UIButtonPtr>::iterator it = mAuiTabButs.find(tabName);
if (it != mAuiTabButs.end())
{
UIButton *tabBut = it->second;
UIFrame *uiContentFrame = mAuiContentFrames[tabBut];
UITabFrame *tabFrame = DynamicCast<UITabFrame>(
uiContentFrame->GetParent()->GetParent());
tabFrame->_SetActiveTab(tabBut->GetName());
if (mActiveTableBut)
{
mActiveTableBut->SetActivate(false);
mActiveTableBut = 0;
}
if (mActiveTableContentFrame)
{
mActiveTableContentFrame->SetActivate(false);
mActiveTableContentFrame = 0;
}
mActiveTableBut = tabBut;
mActiveTableContentFrame = uiContentFrame;
if (mActiveTableBut)
mActiveTableBut->SetActivate(true);
if (mActiveTableContentFrame)
mActiveTableContentFrame->SetActivate(true);
}
}
开发者ID:PhoenixSteam,项目名称:Phoenix3D,代码行数:35,代码来源:PX2UIAuiManager.cpp
示例9: vaoBanChoi
void LayerBaCayAvatar::vaoBanChoi(CCObject *obj,TouchEventType type)
{
UIButton *abc = (UIButton*)obj;
int tag=abc->getTag();
if(type==TOUCH_EVENT_ENDED)
if(tag==1)
{
//yêu cầu làm khách
boost::shared_ptr<IRequest> request (new PlayerToSpectatorRequest());
GameServer::getSingleton().getSmartFox()->Send(request);
btn_vaochoi->setEnabled(true);
btn_dungday->setEnabled(false);
//yêu cầu rời game
boost::shared_ptr<ISFSObject> params (new SFSObject());
boost::shared_ptr<Room> lastRoom = GameServer::getSingleton().getSmartFox()->LastJoinedRoom();
boost::shared_ptr<IRequest> req (new ExtensionRequest("rqlg", params, lastRoom));
GameServer::getSingleton().getSmartFox()->Send(req);
}///
else{
//yêu cầu vào chơi
boost::shared_ptr<IRequest> request (new SpectatorToPlayerRequest());
GameServer::getSingleton().getSmartFox()->Send(request);
CCLog("da vao");
btn_vaochoi->setEnabled(false);
btn_dungday->setEnabled(true);
//yêu cầu join game
boost::shared_ptr<ISFSObject> params (new SFSObject());
boost::shared_ptr<Room> lastRoom = GameServer::getSingleton().getSmartFox()->LastJoinedRoom();
boost::shared_ptr<IRequest> req2 (new ExtensionRequest("rqjg", params, lastRoom));
GameServer::getSingleton().getSmartFox()->Send(req2);
}
}
开发者ID:mrktj,项目名称:iCasino_v2,代码行数:35,代码来源:LayerAvatar_BaCay.cpp
示例10: setLastLoginSever
void FrontCoverLayer::setLastLoginSever()
{
if(m_layout)
{
UIButton* button = m_layout->FindChildObjectByName<UIButton>("latestSeverBt");
if(button)
{
const char* ip = UserData::GetLastIP();
unsigned int port = UserData::GetLastPort();
const char* name = UserData::GetLastServerName();
if(*ip == '\0' || port == 0)
{
button->setEnabled(false);
}
else
{
UILabelTTF* label = button->getTextLabel();
if(label)
{
label->setString(name);
}
}
}
}
}
开发者ID:niuzb,项目名称:hellopetclient,代码行数:25,代码来源:FrontCoverLayer.cpp
示例11: DraggableDialog
CreateNodesDialog::CreateNodesDialog(const Rect & rect)
: DraggableDialog(rect)
{
ControlsFactory::CustomizeDialog(this);
sceneNode = NULL;
scene = NULL;
dialogDelegate = NULL;
propertyList = 0;
header = new UIStaticText(Rect(0, 0, rect.dx, ControlsFactory::BUTTON_HEIGHT));
header->SetFont(ControlsFactory::GetFont12());
header->SetTextColor(ControlsFactory::GetColorLight());
header->SetAlign(ALIGN_HCENTER | ALIGN_VCENTER);
AddControl(header);
float32 buttonY = rect.dy - ControlsFactory::BUTTON_HEIGHT;
float32 buttonX = (rect.dx - ControlsFactory::BUTTON_WIDTH * 2) / 2;
UIButton *btnCancel = ControlsFactory::CreateButton(Vector2(buttonX, buttonY), LocalizedString(L"dialog.cancel"));
btnCancel->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &CreateNodesDialog::OnCancel));
AddControl(btnCancel);
buttonX += ControlsFactory::BUTTON_WIDTH;
UIButton *btnOk = ControlsFactory::CreateButton(Vector2(buttonX, buttonY), LocalizedString(L"dialog.ok"));
btnOk->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &CreateNodesDialog::OnOk));
AddControl(btnOk);
propertyRect = Rect(0, ControlsFactory::BUTTON_HEIGHT, rect.dx, buttonY - ControlsFactory::BUTTON_HEIGHT);
SafeRelease(btnCancel);
SafeRelease(btnOk);
}
开发者ID:boyjimeking,项目名称:dava.framework,代码行数:34,代码来源:CreateNodesDialog.cpp
示例12: GetActiveUIButton
void UIButtonMetadata::UpdateExtraData(HierarchyTreeNodeExtraData& extraData, eExtraDataUpdateStyle updateStyle)
{
if (!VerifyActiveParamID())
{
return;
}
UIButton* button = GetActiveUIButton();
// Button is state-aware.
int statesCount = UIControlStateHelper::GetUIControlStatesCount();
for (int stateID = 0; stateID < statesCount; stateID ++)
{
UIControl::eControlState state = UIControlStateHelper::GetUIControlState(stateID);
UIStaticText* textControl = button->GetStateTextControl(state);
if (!textControl)
{
continue;
}
UpdateStaticTextExtraData(textControl, state, extraData, updateStyle);
}
if (updateStyle == UPDATE_EXTRADATA_FROM_CONTROL)
{
// Also need to recover Dirty Flags in this case.
RecoverPropertyDirtyFlags();
}
}
开发者ID:dima-belsky,项目名称:dava.framework,代码行数:29,代码来源:UIButtonMetadata.cpp
示例13: OnButtonClick_1
void OnButtonClick_1(void *sender, void*args)
{
UIButton *button = static_cast<UIButton*>(sender);
std::cout << "OnButtonClick_1 : " << button->getTag() << std::endl;
button->setPosX(button->getPosX() + 10);
}
开发者ID:LeapTable,项目名称:API,代码行数:8,代码来源:CallBack.cpp
示例14: UIButton
void TestCase::AddReturnButton(UIScreen* pUIScreen)
{
UIButton* pButton = new UIButton(pUIScreen, IMath::VEC2_ZERO, "RETURN");
Vector2 pos(0.0f, ScreenUtil::GetInstance().GetScreenHeight() - pButton->GetSize().y);
pButton->SetPosition(pos);
pButton->ConnectEvent(UMI_CLICKED, this, (MSG_CALLBACK)&TestCase::OnBtnReturnClicked);
}
开发者ID:mshandle,项目名称:spank,代码行数:8,代码来源:TestCase.cpp
示例15: onButtonChats
void LayerChatWindow::onButtonChats( CCObject* pSender, TouchEventType type )
{
UIButton* btnChat = dynamic_cast<UIButton*>(pSender);
if(type == TOUCH_EVENT_ENDED){
CCLog("onButtonChats %s", btnChat->getTitleText());
txtChat->setText( btnChat->getTitleText() );
}
}
开发者ID:mrktj,项目名称:iCasino_v2,代码行数:8,代码来源:LayerChatWindow.cpp
示例16: addTaskBtnCallback
void GameLayer_Menu::addTaskBtnCallback(cocos2d::CCObject *target, SEL_CallFuncO callfun)
{
UIButton* taskBtn = dynamic_cast<UIButton*>(gameMenu->getWidgetByName("SysInfoBtn"));
taskBtn->addReleaseEvent(target, callfun);
taskBtn->setPressedActionEnabled(true);
}
开发者ID:anzhongliu,项目名称:SmallGame_Cocos2dx,代码行数:8,代码来源:GameLayer_Menu.cpp
示例17: onBtnMoveClothes
void PlayScene::onBtnMoveClothes(CCObject *target) {
UIButton* btn = (UIButton *)ui_layer_->getWidgetByName(btn_name[sub_stage_id_]);
if (btn) {
CCPoint move_pos = btn->getTouchMovePos();
btn->setPosition(move_pos);
}
CCLOG("%s\n", __FUNCTION__);
}
开发者ID:f17qh,项目名称:crazyass,代码行数:8,代码来源:play_scene.cpp
示例18: OnEmoClick
void LayerChatWindow::OnEmoClick( CCObject* pSender, TouchEventType type )
{
UIButton* btn = dynamic_cast<UIButton*>(pSender);
if( type == TOUCH_EVENT_ENDED ){
CCLOG("OnEmoClick button tag: %d", btn->getTag());
txtChat->setText( CCString::createWithFormat("%s(%d)", txtChat->getStringValue(), btn->getTag())->getCString() );
}
}
开发者ID:mrktj,项目名称:iCasino_v2,代码行数:8,代码来源:LayerChatWindow.cpp
示例19: itemBtnCallBack
void Scene_GameItem::itemBtnCallBack(cocos2d::CCObject *object)
{
UIButton* btn = (UIButton*)object;
UIImageView* img;
//通过游戏的道具信息获取道具价钱.
sItemData* itemData = CGameInfoMan::sharedInstance().getItemDate(GameShare_Global::shareGlobal()->gameType, btn->getTag());
UILabel* itemInfo = dynamic_cast<UILabel*>(ul->getWidgetByName("Label_591"));
switch (btn->getTag()) {
case Btn_1:
img = dynamic_cast<UIImageView*>(ul->getWidgetByName("IsSelectImg_1"));
break;
case Btn_2:
img = dynamic_cast<UIImageView*>(ul->getWidgetByName("IsSelectImg_2"));
break;
case Btn_3:
img = dynamic_cast<UIImageView*>(ul->getWidgetByName("IsSelectImg_3"));
break;
case Btn_4:
img = dynamic_cast<UIImageView*>(ul->getWidgetByName("IsSelectImg_4"));
break;
default:
break;
}
if (img->isVisible()) {
img->setVisible(false);
if (itemData) {
CCString infoStr;
infoStr.initWithFormat("%s:%s",itemData->ItemName.c_str(),itemData->ItemDetail.c_str());
itemInfo->setText(infoStr.getCString());
needGold -= itemData->CurrencyValue;
}
}else{
img->setVisible(true);
if (itemData) {
CCString infoStr;
infoStr.initWithFormat("%s:%s",itemData->ItemName.c_str(),itemData->ItemDetail.c_str());
itemInfo->setText(infoStr.getCString());
needGold += itemData->CurrencyValue;
if (CPlayerInfoMan::sharedInstance().getPlayerInfo().nMoney < needGold) {
GameLayer_Alert *alertUl = GameLayer_Alert::creatWithOnlySure(Type_OnlySure);
needGold -= itemData->CurrencyValue;
alertUl->setText(GET_STRING_CSV(1010000021));
this->addChild(alertUl,1);
img->setVisible(false);
}
}
}
this->setItemByTag(btn->getTag());
}
开发者ID:anzhongliu,项目名称:SmallGame_Cocos2dx,代码行数:57,代码来源:Scene_GameItem.cpp
示例20: defaultPlay
void UIComponentTest::defaultPlay()
{
CCComRender *render = static_cast<CCComRender*>(m_rootNode->getChildByTag(10025)->getComponent("GUIComponent"));
cocos2d::ui::TouchGroup* touchGroup = static_cast<cocos2d::ui::TouchGroup*>(render->getNode());
UIWidget* widget = static_cast<UIWidget*>(touchGroup->getWidgetByName("Panel_154"));
UIButton* button = static_cast<UIButton*>(widget->getChildByName("Button_156"));
button->addTouchEventListener(this, toucheventselector(UIComponentTest::touchEvent));
}
开发者ID:fuguelike,项目名称:cocos2d-x,代码行数:10,代码来源:SceneEditorTest.cpp
注:本文中的UIButton类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论