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


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

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


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

示例1: init

bool ControlButtonTest_Event::init()
{
    if (ControlScene::init())
    {
        auto screenSize = Director::getInstance()->getWinSize();

        // Add a label in which the button events will be displayed
        setDisplayValueLabel(Label::createWithTTF("No Event", "fonts/Marker Felt.ttf", 32));
        _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1));
        _displayValueLabel->setPosition(screenSize.width / 2.0f, screenSize.height / 2.0f);
        addChild(_displayValueLabel, 1);

        setDisplayBitmaskLabel(Label::createWithTTF("No bitmask event", "fonts/Marker Felt.ttf", 24));
        _displayBitmaskLabel->setAnchorPoint(Vec2(0.5f, -1));
        Vec2 bitmaskLabelPos = _displayValueLabel->getPosition() - Vec2(0, _displayBitmaskLabel->getBoundingBox().size.height);
        _displayBitmaskLabel->setPosition(bitmaskLabelPos);
        addChild(_displayBitmaskLabel, 1);

        // Add the button
        auto backgroundButton = ui::Scale9Sprite::create("extensions/button.png");
        auto backgroundHighlightedButton = ui::Scale9Sprite::create("extensions/buttonHighlighted.png");
        
        auto titleButton = Label::createWithTTF("Touch Me!", "fonts/Marker Felt.ttf", 30);

        titleButton->setColor(Color3B(159, 168, 176));
        
        ControlButton *controlButton = ControlButton::create(titleButton, backgroundButton);
        controlButton->setBackgroundSpriteForState(backgroundHighlightedButton, Control::State::HIGH_LIGHTED);
        controlButton->setTitleColorForState(Color3B::WHITE, Control::State::HIGH_LIGHTED);
        
        controlButton->setAnchorPoint(Vec2(0.5f, 1));
        controlButton->setPosition(screenSize.width / 2.0f, screenSize.height / 2.0f);
        addChild(controlButton, 1);

        // Add the black background
        auto background = ui::Scale9Sprite::create("extensions/buttonBackground.png");
        background->setContentSize(Size(300, 170));
        background->setPosition(screenSize.width / 2.0f, screenSize.height / 2.0f);
        addChild(background);
        
        // Sets up event handlers
        controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchDownAction), Control::EventType::TOUCH_DOWN);
        controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchDragInsideAction), Control::EventType::DRAG_INSIDE);
        controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchDragOutsideAction), Control::EventType::DRAG_OUTSIDE);
        controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchDragEnterAction), Control::EventType::DRAG_ENTER);
        controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchDragExitAction), Control::EventType::DRAG_EXIT);
        controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchUpInsideAction), Control::EventType::TOUCH_UP_INSIDE);
        controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchUpOutsideAction), Control::EventType::TOUCH_UP_OUTSIDE);
        controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchCancelAction), Control::EventType::TOUCH_CANCEL);
        // test for issue 2882
        controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchBitmaskAction),
            Control::EventType::TOUCH_DOWN | Control::EventType::DRAG_INSIDE | Control::EventType::DRAG_OUTSIDE | Control::EventType::DRAG_ENTER | Control::EventType::DRAG_EXIT | Control::EventType::TOUCH_UP_INSIDE | Control::EventType::TOUCH_UP_OUTSIDE | Control::EventType::TOUCH_CANCEL | Control::EventType::VALUE_CHANGED);

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

示例2: createButton

ControlButton* ButtonUtils::createButton(const char *normalFrame, 
										 const char *highLightFrame,
										 const char *disableFrame,
										 cocos2d::Size size,
										 const char *label,
										 float labelSize,
										 Color3B labelColor)
{
    Scale9Sprite *normal = Scale9Sprite::createWithSpriteFrame(SpriteFrameCache::getInstance()->getSpriteFrameByName(normalFrame));
    Scale9Sprite *highLight = Scale9Sprite::createWithSpriteFrame(SpriteFrameCache::getInstance()->getSpriteFrameByName(highLightFrame));
    Scale9Sprite *disable = Scale9Sprite::createWithSpriteFrame(SpriteFrameCache::getInstance()->getSpriteFrameByName(disableFrame));
    ControlButton *btn = ControlButton::create(label, "Arial", labelSize);
    btn->setPreferredSize(size);//设置按钮首选大小
    btn->setBackgroundSpriteForState(normal, Control::State::NORMAL);
    btn->setBackgroundSpriteForState(highLight, Control::State::HIGH_LIGHTED);
    btn->setBackgroundSpriteForState(disable, Control::State::DISABLED);
    btn->setTitleColorForState(labelColor, Control::State::NORMAL);
    btn->setTitleColorForState(labelColor, Control::State::HIGH_LIGHTED);
    btn->setTitleColorForState(labelColor, Control::State::DISABLED);
    //btn->setTouchPriority(0);
    
    return btn;
}
开发者ID:,项目名称:,代码行数:23,代码来源:

示例3:

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

示例4:

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


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