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


C++ CCControlButton::setMargins方法代码示例

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


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

示例1: init

bool HelloScene::init()
{
    if (!CCLayer::init())
    {
        return false;
    }

    CCSprite *bg = CCSprite::create("background.png");
    bg->setPosition(VisibleRect::center());
    //CCSize &winSize = CCDirector::sharedDirector()->getWinSize();
    //float scalex = winSize.width / 480;
    //float scaley = winSize.height / 800;
    //bg->setScaleX(scalex);
    //bg->setScaleY(scaley);
    addChild(bg);

    const CCPoint &center = VisibleRect::center();

    CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
        "CloseNormal.png",
        "CloseSelected.png",
        this,
        menu_selector(HelloScene::menuCloseCallback));
    pCloseItem->setPosition(ccp(VisibleRect::rightBottom().x - pCloseItem->getContentSize().width/2 ,
        pCloseItem->getContentSize().height/2));
    CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
    pMenu->setPosition(CCPointZero);
    this->addChild(pMenu, 1);

    CCLabelTTF *title = CCLabelTTF::create("Lovexin Plane Chess", "Arial", 40);
    title->setPosition(ccp(center.x, center.y + 250));
    CCLabelTTF *author = CCLabelTTF::create("made by Waltz Duyf", "Arial", 20);
    author->setPosition(ccp(center.x + 100, center.y + 200));
    addChild(title);
    addChild(author);

    addSetupSwitch(ccp(center.x - 120, center.y + 50 ), "RED", ccc3(255, 0, 0), FORCE_COLOR_RED);//, cccontrol_selector(HelloScene::valueChangedJoinInR), cccontrol_selector(HelloScene::valueChangedAIR));
    addSetupSwitch(ccp(center.x - 120, center.y - 10 ), "YEL", ccc3(234, 165, 0), FORCE_COLOR_YELLOW);//, cccontrol_selector(HelloScene::valueChangedJoinInY), cccontrol_selector(HelloScene::valueChangedAIY));
    addSetupSwitch(ccp(center.x - 120, center.y - 70 ), "GRE", ccc3(0, 255, 0), FORCE_COLOR_GREEN);//, cccontrol_selector(HelloScene::valueChangedJoinInG), cccontrol_selector(HelloScene::valueChangedAIG));
    addSetupSwitch(ccp(center.x - 120, center.y - 130), "BLU", ccc3(0, 144, 255), FORCE_COLOR_BLUE);//, cccontrol_selector(HelloScene::valueChangedJoinInB), cccontrol_selector(HelloScene::valueChangedAIB));

    CCScale9Sprite *backgroundButton = CCScale9Sprite::create("button.png");
    CCScale9Sprite *backgroundHighlightedButton = CCScale9Sprite::create("buttonHighlighted.png");
    CCLabelTTF *titleButton = CCLabelTTF::create("Play Now", "Arial", 30);
    titleButton->setColor(ccc3(159, 168, 176));
    CCControlButton *button = CCControlButton::create(titleButton, backgroundButton);
    button->setBackgroundSpriteForState(backgroundHighlightedButton, CCControlStateHighlighted);
    button->setTitleColorForState(ccWHITE, CCControlStateHighlighted);
    button->setMargins(70, 20);
    button->setPosition(ccp(center.x, center.y - 250));
    addChild(button);
    button->addTargetWithActionForControlEvents(this, cccontrol_selector(HelloScene::playBtnCallback), CCControlEventTouchUpInside);

    return true;
}
开发者ID:waltzduyf,项目名称:cocos2d_game,代码行数:55,代码来源:HelloScene.cpp


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