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


C++ CCControlSlider::setTouchPriority方法代码示例

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


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

示例1: initContent

void GameSet::initContent()
{
    CCSize winSize = CCDirector::sharedDirector()->getWinSize();
    CCLayerColor *colorlayer = CCLayerColor::create(ccc4(0, 0, 0, 120));
    addChild(colorlayer);
    colorlayer->setPosition(ccp(-winSize.width/2, -winSize.height/2));
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("common/common.plist");
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("ui/gameSet/gameSet.plist");
    
    CCSprite *bg = CCSprite::create("common/commonBg_451_305.png");
    addChild(bg);
    
    CCSprite *titleBg = CCSprite::createWithSpriteFrameName("common_titleBg.png");
    bg->addChild(titleBg);
    titleBg->setPosition(ccp(bg->getContentSize().width/2 + 50, bg->getContentSize().height));
    
    CCLabelBMFont *title = CCLabelBMFont::create("设置", "font/font_uiTitle.fnt");
    titleBg->addChild(title);
    title->setPosition(ccp(titleBg->getContentSize().width/2 - 50, titleBg->getContentSize().height/2));
    
    CCScale9Sprite *frame = CCScale9Sprite::create("common/common_scale_1.png");
    frame->setPreferredSize(CCSizeMake(328, 150));
    frame->setAnchorPoint(ccp(0.5, 0.5));
    bg->addChild(frame);
    frame->setPosition(ccp(bg->getContentSize().width/2, bg->getContentSize().height/2 + 40));

    
//    CCSprite *title = CCSprite::createWithSpriteFrameName("set_title.png");
//    bg->addChild(title);
//    title->setPosition(ccp(bg->getContentSize().width/2, bg->getContentSize().height - 20));
    
    
    CCControlButton *closeBtn = INSTANCE(ButtonUtils)->createButton("common_backBtn.png", CCSizeMake(75, 81), "");
    bg->addChild(closeBtn);
    closeBtn->setPosition(ccp(bg->getContentSize().width - 20, bg->getContentSize().height - 20));
    closeBtn->addTargetWithActionForControlEvents(this, cccontrol_selector(GameSet::close), CCControlEventTouchUpInside);
    
    CCLabelBMFont *musicLabel = CCLabelBMFont::create("音乐", "font/font_common.fnt");
    bg->addChild(musicLabel);
    musicLabel->setPosition(ccp(115, 235));
    
    CCControlSlider *musicSlider = CCControlSlider::create(CCSprite::createWithSpriteFrameName("set_barFrame.png"), CCSprite::createWithSpriteFrameName("set_barFrame.png"), CCSprite::createWithSpriteFrameName("set_barBtn.png"));
    musicSlider->setAnchorPoint(ccp(0.5f, 1.0f));
    musicSlider->setMinimumValue(0.0f); // Sets the min value of range
    musicSlider->setMaximumValue(1.0f); // Sets the max value of range
    musicSlider->setTag(1);
    musicSlider->addTargetWithActionForControlEvents(this, cccontrol_selector(GameSet::musicCallBack), CCControlEventValueChanged);
    musicSlider->setPosition(ccp(260, 250));
    musicSlider->setTouchPriority(0);
    float musicVolume = CCUserDefault::sharedUserDefault()->getFloatForKey(GameSet_musicVolume, 0.5);
    musicSlider->setValue(musicVolume);
    bg->addChild(musicSlider);
    
    CCLabelBMFont *soundLabel = CCLabelBMFont::create("音效", "font/font_common.fnt");
    bg->addChild(soundLabel);
    soundLabel->setPosition(ccp(115, 185));
    
    CCControlSlider *soundSlider = CCControlSlider::create(CCSprite::createWithSpriteFrameName("set_barFrame.png"), CCSprite::createWithSpriteFrameName("set_barFrame.png"), CCSprite::createWithSpriteFrameName("set_barBtn.png"));
    soundSlider->setAnchorPoint(ccp(0.5f, 1.0f));
    soundSlider->setMinimumValue(0.0f); // Sets the min value of range
    soundSlider->setMaximumValue(1.0f); // Sets the max value of range
    soundSlider->setTag(1);
    soundSlider->addTargetWithActionForControlEvents(this, cccontrol_selector(GameSet::soundCallBack), CCControlEventValueChanged);
    soundSlider->setPosition(ccp(260, 200));
    soundSlider->setTouchPriority(0);
    float soundVolume = CCUserDefault::sharedUserDefault()->getFloatForKey(GameSet_soundVolume, 0.5);
    soundSlider->setValue(soundVolume);
    bg->addChild(soundSlider);
    
    
    CCControlButton *btn1 = INSTANCE(ButtonUtils)->createButton("set_guide.png", CCSizeMake(84, 87), "");
    
    CCControlButton *btn3 = INSTANCE(ButtonUtils)->createButton("set_contact.png", CCSizeMake(83, 84), "");
    CCControlButton *btn4 = INSTANCE(ButtonUtils)->createButton("set_develep.png", CCSizeMake(83, 92), "");
    
    bg->addChild(btn1);
    
    bg->addChild(btn3);
    bg->addChild(btn4);
    
    if(showHelp){
        wikiBtn = INSTANCE(ButtonUtils)->createButton("set_wiki.png", CCSizeMake(87, 89), "");
        bg->addChild(wikiBtn);
        btn1->setPosition(ccp(80, 50));
        wikiBtn->setPosition(ccp(180, 50));
        btn3->setPosition(ccp(280, 50));
        btn4->setPosition(ccp(380, 50));
        
        wikiBtn->addTargetWithActionForControlEvents(this, cccontrol_selector(GameSet::btn2Handler), CCControlEventTouchUpInside);
    }else{
        btn1->setPosition(ccp(80, 50));
        btn3->setPosition(ccp(230, 50));
        btn4->setPosition(ccp(380, 50));
    }
    
    btn1->addTargetWithActionForControlEvents(this, cccontrol_selector(GameSet::btn1Handler), CCControlEventTouchUpInside);
    btn3->addTargetWithActionForControlEvents(this, cccontrol_selector(GameSet::btn3Handler), CCControlEventTouchUpInside);
    btn4->addTargetWithActionForControlEvents(this, cccontrol_selector(GameSet::btn4Handler), CCControlEventTouchUpInside);
    
    
//.........这里部分代码省略.........
开发者ID:qokelate,项目名称:ThreeKingDoms,代码行数:101,代码来源:GameSet.cpp


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