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


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

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


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

示例1: 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

示例2: init

bool SkillTableView::init()
{
    if (!Node::init())
        return false;

    LayerColor* bg = LayerColor::create(Color4B(255, 255, 255, 127), 450, 500);
    bg->setPosition(bg->getContentSize()/-2);
    this->addChild(bg, -1);
    
    CCLabelTTF* title = CCLabelTTF::create("技能列表", "fonts/Marker Felt.ttf", 40);
    title->setPosition(Point(bg->getContentSize().width/2, bg->getContentSize().height-30));
    bg->addChild(title);
    
    ControlButton* button = ControlButton::create(Scale9Sprite::create("ui/closed_normal.png"));
    button->setBackgroundSpriteForState(Scale9Sprite::create("ui/closed_selected.png"), Control::State::HIGH_LIGHTED);
    button->setPreferredSize(Size(57, 58));
    button->setPosition(ccpSub(ccpAdd(bg->getPosition(), bg->getContentSize()), button->getContentSize()/2));
    this->addChild(button);
    button->addTargetWithActionForControlEvents(GAME_UILAYER, cccontrol_selector(GameInfoUIController::removeSmallMenuAndButton), Control::EventType::TOUCH_UP_INSIDE);
   // button->setTouchPriority(0);
    
    m_skillTableView = TableView::create(this, Size(420, 420));
    m_skillTableView->setPosition(Point(15, 15));
   // m_skillTableView->setDirection(kCCScrollViewDirectionVertical);
    m_skillTableView->setDelegate(this);
   // m_skillTableView->setVerticalFillOrder(kCCTableViewFillTopDown);
    bg->addChild(m_skillTableView);
    m_skillTableView->reloadData();
    return true;
}
开发者ID:gujianhesong,项目名称:GujianDream,代码行数:30,代码来源:SkillTableView.cpp

示例3: init

bool PropColumnMenu::init()
{
    if (!Layer::init())
        return false;
    
    this->setTouchEnabled(true);
    
    Sprite* bg = Sprite::create("ui/prop_column.png");
    this->addChild(bg);
    
    m_propColumn = LayerColor::create(ccc4(255, 255, 255, 0), GRID_WIDTH*COL, GRID_HEIGHT*ROW);
    m_propColumn->setContentSize(Size(GRID_WIDTH*COL, GRID_HEIGHT*ROW));
    m_propColumn->setPosition(Point(PROP_X, PROP_Y));
    bg->addChild(m_propColumn);
    
    ControlButton* button = ControlButton::create(ui::Scale9Sprite::create("ui/closed_normal.png"));
    button->setBackgroundSpriteForState(ui::Scale9Sprite::create("ui/closed_selected.png"), Control::State::HIGH_LIGHTED);
    button->setPreferredSize(Size(57, 58));
    button->setPosition(ccpSub(ccpAdd(bg->getPosition(), bg->getContentSize()/2), button->getContentSize()/2));
    this->addChild(button);
    button->addTargetWithActionForControlEvents(GAME_UILAYER, cccontrol_selector(GameInfoUIController::removeSmallMenuAndButton), Control::EventType::TOUCH_UP_INSIDE);
   // button->setTouchPriority(0);
    
    for (int i=0; i<12; i++)
    {
        m_propVec[i] = PropIconShow::create(PropSystem::getPropInfo(i+1));
        m_propColumn->addChild(m_propVec[i]);
    }

    return true;
}
开发者ID:dzwdyc,项目名称:codesssssssss,代码行数:31,代码来源:PropColumn.cpp

示例4: 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

示例5: init

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

        auto layer = Node::create();
        addChild(layer, 1);
        
        int space = 10; // px
        
        double max_w = 0, max_h = 0;
        for (int i = 0; i < 3; i++)
        {
            for (int j = 0; j < 3; j++)
            {
                // Add the buttons
                ControlButton *button = standardButtonWithTitle(StringUtils::format("%d",rand() % 30).c_str());
                button->setAdjustBackgroundImage(false);  // Tells the button that the background image must not be adjust
                                                    // It'll use the prefered size of the background image
                button->setPosition(button->getContentSize().width / 2 + (button->getContentSize().width + space) * i,
                                       button->getContentSize().height / 2 + (button->getContentSize().height + space) * j);
                layer->addChild(button);
                
                max_w = MAX(button->getContentSize().width * (i + 1) + space  * i, max_w);
                max_h = MAX(button->getContentSize().height * (j + 1) + space * j, max_h);
            }
        }
        
        layer->setAnchorPoint(Vec2(0.5, 0.5));
        layer->setContentSize(Size(max_w, max_h));
        layer->setPosition(screenSize.width / 2.0f, screenSize.height / 2.0f);
        
        // Add the black background
        auto backgroundButton = ui::Scale9Sprite::create("extensions/buttonBackground.png");
        backgroundButton->setContentSize(Size(max_w + 14, max_h + 14));
        backgroundButton->setPosition(screenSize.width / 2.0f, screenSize.height / 2.0f);
        addChild(backgroundButton);
        return true;
    }
    return false;
}
开发者ID:asuo1986,项目名称:own,代码行数:42,代码来源:CCControlButtonTest.cpp

示例6: 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

示例7: 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


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