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


C++ ControlButton类代码示例

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


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

示例1: addChild

void AssetsUpdateLayer::updateLayerMessageBox()
{

    SpriteFrameCache::getInstance()->addSpriteFramesWithFile("ccb/ccbResources/SystemLoading.plist");

    CCLayer* layer = CCLayer::create();
    layer->ignoreAnchorPointForPosition(false);
    layer->setContentSize(Size(960, 640));
    layer->setPosition(Point(Director::getInstance()->getWinSize().width * 0.5, Director::getInstance()->getWinSize().height * 0.5));
    layer->setScale(Director::getInstance()->getWinSize().width / 960);
    addChild(layer, 1);

    Sprite* messageboxSprite = Sprite::createWithSpriteFrameName("set_floor_v1.png");
    messageboxSprite->setPosition(Point(480, 320));
    layer->addChild(messageboxSprite, 1);

    LabelTTF* labelContent = LabelTTF::create(Localization::getInstance()->getValueByKey("Loading_warning_need_update"), "Helvetica",32);
    labelContent->setPosition(Point(480, 420));
    layer->addChild(labelContent, 1);

    ControlButton* btn = ControlButton::create(LabelTTF::create(Localization::getInstance()->getValueByKey("BUTTON_DONE"), "Helvetica", 32), Scale9Sprite::createWithSpriteFrameName("set_button2.png"));
    btn->setPreferredSize(CCSize(191,70));
    btn->setPosition(Point(480, 220));
    btn->addTargetWithActionForControlEvents(this, cccontrol_selector(AssetsUpdateLayer::GoToAppPage), Control::EventType::TOUCH_UP_INSIDE);
    layer->addChild(btn, 1);

}
开发者ID:sharpfforg,项目名称:us,代码行数:27,代码来源:AssetsUpdateLayer.cpp

示例2: ControlButton

ControlButton* ControlButton::create(Node* label, Scale9Sprite* backgroundSprite)
{
    ControlButton *pRet = new ControlButton();
    pRet->initWithLabelAndBackgroundSprite(label, backgroundSprite);
    pRet->autorelease();
    return pRet;
}
开发者ID:henyouqian,项目名称:cocos2d-x-3.0alpha0,代码行数:7,代码来源:CCControlButton.cpp

示例3: DetectControl

void GamepadPage::DetectControl(wxCommandEvent& event)
{
	ControlButton* btn = (ControlButton*)event.GetEventObject();

	// find device :/
	Device* const dev = g_controller_interface.FindDevice(controller->default_device);
	if (dev)
	{
		btn->SetLabel(_("[ waiting ]"));

		// apparently, this makes the "waiting" text work on Linux
		wxTheApp->Yield();

		std::lock_guard<std::recursive_mutex> lk(m_plugin.controls_lock);
		Device::Control* const ctrl = btn->control_reference->Detect(DETECT_WAIT_TIME, dev);

		// if we got input, update expression and reference
		if (ctrl)
		{
			wxString control_name = ctrl->GetName();
			wxString expr;
			GetExpressionForControl(expr, control_name);
			btn->control_reference->expression = expr;
			g_controller_interface.UpdateReference(btn->control_reference, controller->default_device);
		}
	}

	UpdateGUI();
}
开发者ID:Annovae,项目名称:Dolphin-Core,代码行数:29,代码来源:InputConfigDiag.cpp

示例4: choicesCallback

void ChoiceLayer::choicesCallback(Ref* sender, Control::EventType event)
{
    ControlButton *pressedBtn = (ControlButton*)sender;
    _selectedTag = pressedBtn->getTag();
	CCLOG("Select tag : %d", _selectedTag);
	for (auto child : getChildren())
		child->setOpacity(0);
}
开发者ID:mdifferent,项目名称:Sanyu-with-cocos2dx-3.2,代码行数:8,代码来源:ChoiceLayer.cpp

示例5: standardButtonWithTitle

ControlButton* standardButtonWithTitle( const char * bgname, const char * bgseledname, const char * title){

	//Creates and return a button with a default background and title color.
//    Scale9Sprite *backgroundButton = Scale9Sprite::create(bgname);//按下前
//    Scale9Sprite *backgroundHighlightedButton = Scale9Sprite::create(bgseledname);//按下后
	

	ControlButton* btn = ControlButton::create();
	btn->setPreferredSize(Size(522, 88));

	Scale9Sprite*	normal = Scale9Sprite::create(bgname);
	Scale9Sprite*	select = Scale9Sprite::create(bgseledname);
	Scale9Sprite* hightlight = Scale9Sprite::create(bgseledname);
	Scale9Sprite* disable = Scale9Sprite::create(bgname);
	
	btn->setBackgroundSpriteForState(normal, Control::State::NORMAL);
	btn->setBackgroundSpriteForState(select, Control::State::SELECTED);
	btn->setBackgroundSpriteForState(hightlight, Control::State::HIGH_LIGHTED);
	btn->setBackgroundSpriteForState(disable, Control::State::DISABLED);
	
	
    LabelTTF *titleButton = LabelTTF::create(title, "AmericanTypewriter", 30);//添加文字
	titleButton->setAnchorPoint(Point(0.5f, 0.5f));
	titleButton->setPosition(Point(btn->getContentSize().width/2, btn->getContentSize().height/2));
	titleButton->setColor(Color3B::BLACK);//设置文字点击前的颜色
	titleButton->setTag(1000);
	btn->addChild(titleButton);

    return btn;
}
开发者ID:jiangchao1987,项目名称:crazyvideo,代码行数:30,代码来源:Tools.cpp

示例6: ControlButton

ControlButton* ControlButton::create()
{
    ControlButton *pControlButton = new ControlButton();
    if (pControlButton && pControlButton->init())
    {
        pControlButton->autorelease();
        return pControlButton;
    }
    CC_SAFE_DELETE(pControlButton);
    return nullptr;
}
开发者ID:skatpgusskat,项目名称:December,代码行数:11,代码来源:CCControlButton.cpp

示例7: Point

void TDDSubMenu::setupHeader(const Color4B &headerColor)
{
	GLfloat parentH = this->getContentSize().height;
	GLfloat width = this->getContentSize().width;
	GLfloat height = kHeaderHeight;
	
	LayerColor *headerLayer = LayerColor::create(headerColor, width, height);
	Point pos = Point(0, parentH - height);
	headerLayer->setPosition(pos);
	this->addChild(headerLayer);
	
	
	// Setting Buttons
	float scale = TDDHelper::getBestScale();
	// Size screenSize = TDDHelper::getScreenSize();
	int midY = height/2;
	int buttonW = (int)(scale * 50);
	int buttonH = height;
	int leftButtonX = buttonW / 2;
	int rightButtonX = width - leftButtonX;
	int midX = width/2;
	

	Size size = Size(buttonW, buttonH);

	ControlButton *button;
	pos.x = leftButtonX;
	pos.y = midY;
	button = createButton("back", kActionTagBack, pos, size);
	headerLayer->addChild(button);
	mBackButton = button;
	
	pos.x = rightButtonX;
	pos.y = midY;
	button = createButton("hide", kActionTagToggle, pos, size);
	headerLayer->addChild(button);
	button->addTargetWithActionForControlEvents(this,
												cccontrol_selector(TDDSubMenu::touchUpInsideAction),
												Control::EventType::TOUCH_UP_INSIDE);
	mToggleButton = button;
	
	// Label
	Label *title = Label::createWithSystemFont("MENU", "Arial", 15);
	title->setColor(Color3B::WHITE);
	title->setPosition(Point(midX, midY));
	headerLayer->addChild(title);
	
	
	//
	mHeaderLayer = headerLayer;
}
开发者ID:dwdcth,项目名称:SimpleTDD-cocos2dx,代码行数:51,代码来源:TDDSubMenu.cpp

示例8: addChild

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

示例9:

ControlButton *ControlButtonTest_HelloVariableSize::standardButtonWithTitle(const char * title)
{
    /** Creates and return a button with a default background and title color. */
    auto backgroundButton = ui::Scale9Sprite::create("extensions/button.png");
    auto backgroundHighlightedButton = ui::Scale9Sprite::create("extensions/buttonHighlighted.png");
    
    auto titleButton = Label::createWithTTF(title, "fonts/Marker Felt.ttf", 30);

    titleButton->setColor(Color3B(159, 168, 176));
    
    ControlButton *button = ControlButton::create(titleButton, backgroundButton);
    button->setBackgroundSpriteForState(backgroundHighlightedButton, Control::State::HIGH_LIGHTED);
    button->setTitleColorForState(Color3B::WHITE, Control::State::HIGH_LIGHTED);

    return button;
}
开发者ID:asuo1986,项目名称:own,代码行数:16,代码来源:CCControlButtonTest.cpp

示例10: log

void SpineTest::changeAnime(Object *sender, Control::EventType type)
{
	if(mAnime == NULL) {
		log("mAnime is NULL");
		return;
	}
	
	//
	ControlButton *button = dynamic_cast<ControlButton *>(sender);
	if(button == NULL) {
		return;
	}
	
	//
	int tag = button->getTag();
	
	switch(tag) {
		case kTagButtonWalk:
		{
			log("walk");
			mAnime->setAnimation(0, "walk", true);
			break;
		}
			
		case kTagButtonJump:
		{
			log("jump");
			mAnime->setAnimation(0, "jump", true);
			break;
		}
			
		case kTagButtonHurt:
		{
			log("hurt");
			mAnime->setAnimation(0, "hurt", true);
			break;
		}
			
		case kTagButtonIdle:
		{
			log("idle");
			mAnime->setAnimation(0, "idle", true);
			break;
		}

	}
}
开发者ID:tklee1975,项目名称:ccx3-game,代码行数:47,代码来源:SpineTest.cpp

示例11: init

bool UndercoverGameScene::init()
{
    if ( !Layer::init() )
    {
        return false;
    }
    Size visibleSize = Director::getInstance()->getVisibleSize();
    Vec2 origin = Director::getInstance()->getVisibleOrigin();
    ControlButton* back = ControlButton::create("Back", "Arial", 40);
    back->addTargetWithActionForControlEvents(this, cccontrol_selector(UndercoverGameScene::buttonBack), Control::EventType::TOUCH_UP_INSIDE);
    back->setAnchorPoint(Point(0.5,0.5));
    back->setZoomOnTouchDown(true);
    back->setPosition(Vec2(visibleSize.width - 100,
                           visibleSize.height - 100));
    this->addChild(back, 1);
    return true;
}
开发者ID:LLF,项目名称:boardgameking-client,代码行数:17,代码来源:UndercoverGameScene.cpp

示例12: answerAnimation

void GameScene::answerAnimation( int answerIndex){
	
	GameAnswerState st;
	ControlButton* btn;
	switch ( answerIndex ) {
		case 1:
		//	st = answerOneState_;
			btn = btn1;
			break;
		case 2:
		//	st = answerTwoState_;
			btn = btn2;
		    break;
		case 3:
		//	st = answerThreeState_;
			btn = btn3;
			break;
		case 4:
		//	st = answerFouState_;
			btn = btn4;
			break;
		default:
			break;
	}
	st = answerStateArr_[ answerIndex - 1];
	
	std::string correctwrongImgStr;
	
	if ( st == GameStateAnswerStateRight ) {
		//right
		correctwrongImgStr = "play_correct.png";
	}else{
		correctwrongImgStr = "play_wrong.png";
	}
	
	btn->setEnabled(false);
	Sprite* sp = Sprite::create(correctwrongImgStr);
	sp->setPosition( Point( btn->getPositionX() - btn->getContentSize().width/2 + sp->getContentSize().width, btn->getPositionY()));
	this->addChild(sp);
	
//	CCLabelBMFont* label = CCLabelBMFont::create("23","prim30.fnt");
//	label->setColor(Color3B::BLACK);
//	label->setPosition(sp->getPosition());
//	this->addChild(label);
	
}
开发者ID:jiangchao1987,项目名称:crazyvideo,代码行数:46,代码来源:GameScene.cpp

示例13:

ControlButton *AboutLayer::standardButtonWithTitle(const std::string& string)
{
	/** Creates and return a button with a default background and title color. */
	auto backgroundButton = Scale9Sprite::create("button.png");
	auto backgroundHighlightedButton = Scale9Sprite::create("buttonHighlighted.png");

	auto titleButton = LabelTTF::create(string, "Marker Felt", 50);
    //auto label = LabelTTF::create("中国", "Marker Felt", 30);
	titleButton->setColor(Color3B(159, 168, 176));

	ControlButton *button = ControlButton::create(titleButton, backgroundButton);
	button->setBackgroundSpriteForState(backgroundHighlightedButton, Control::State::HIGH_LIGHTED);
	button->setTitleColorForState(Color3B::WHITE, Control::State::HIGH_LIGHTED);
	button->addTargetWithActionForControlEvents(this, cccontrol_selector(AboutLayer::touchUpInsideAction), Control::EventType::TOUCH_UP_INSIDE);
	this->addChild(button);
	return button;
}
开发者ID:ezhong0812,项目名称:qicai,代码行数:17,代码来源:aboutScene.cpp

示例14: onTouchMoved

void SkillTableView::onTouchMoved(Touch *pTouch, Event *pEvent)
{
    Point point = pTouch->getLocation();
    
    if (m_pEditingSkill == NULL)
        return;
        
    m_pEditingSkill->setPosition(point);
    
    if (m_pEditingBtn)
    {
        Rect rect;
        rect.origin = m_pEditingBtn->convertToWorldSpace(Point::ZERO);
        rect.size = m_pEditingBtn->getContentSize();
        if (!rect.containsPoint(point))
        {
            m_pEditingSkill->setOpacity(127);
            m_pEditingBtn->stopAllActions();
            ScaleTo* scaleTo = ScaleTo::create(0.1f, 1.0f);
            m_pEditingBtn->runAction(scaleTo);
            m_pEditingBtn = NULL;
        }
    }
    
    if (m_pEditingBtn == NULL)
    {
        for (unsigned int i=0; i<3; i++)
        {
            ControlButton* btn = GAME_UILAYER->getOperationMenu()->getSkillAttackBtn(i);
            Rect rect;
            rect.origin = btn->convertToWorldSpace(Point::ZERO);
            rect.size = btn->getContentSize();
            
            if (rect.containsPoint(point))
            {
                m_pEditingSkill->setOpacity(255);
                m_pEditingBtn = btn;
                m_pEditingBtn->stopAllActions();
                ScaleTo* scaleTo = ScaleTo::create(0.1f, 1.1f);
                m_pEditingBtn->runAction(scaleTo);
                break;
            }
        }
    }
}
开发者ID:gujianhesong,项目名称:GujianDream,代码行数:45,代码来源:SkillTableView.cpp

示例15: onTouchMoved

void PropColumnMenu::onTouchMoved(Touch *pTouch, Event *pEvent)
{
    Point point = pTouch->getLocation();
    
    m_editProp->setPosition(point);
    
    do
    {
        ControlButton* btn = GAME_UILAYER->getOperationMenu()->getDrugsBtn();
        
        Rect rect;
        rect.origin = btn->convertToWorldSpace(Point::ZERO);
        rect.size = btn->getContentSize();
        if (rect.containsPoint(point))
        {
            CC_BREAK_IF(m_editProp->getOpacity() == 255);
            m_editProp->setOpacity(255);
            btn->stopAllActions();
            ScaleTo* scaleTo = ScaleTo::create(0.1f, 1.1f);
            btn->runAction(scaleTo);
        }
        else
        {
            CC_BREAK_IF(m_editProp->getOpacity() == 127);
            m_editProp->setOpacity(127);
            btn->stopAllActions();
            ScaleTo* scaleTo = ScaleTo::create(0.1f, 1.0f);
            btn->runAction(scaleTo);
        }
    }
    while (0);
}
开发者ID:dzwdyc,项目名称:codesssssssss,代码行数:32,代码来源:PropColumn.cpp


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