本文整理汇总了C++中CCControlSlider::setTag方法的典型用法代码示例。如果您正苦于以下问题:C++ CCControlSlider::setTag方法的具体用法?C++ CCControlSlider::setTag怎么用?C++ CCControlSlider::setTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCControlSlider
的用法示例。
在下文中一共展示了CCControlSlider::setTag方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
bool SettingsLayer::init(){
if (!DialogLayer::init()) {
return false;
}
this->setTitle("设 置");
CCLabelTTF* acountLabel=CCLabelTTF::create("账 号:", "", 20);
acountLabel->setPosition(S_RM->getPositionWithName("setting_acountLabel"));
acountLabel->setColor(ccc3(0, 0, 0));
this->addChild(acountLabel);
Button9* userLabel=Button9::create("",CCSizeMake(400, 50),20);
m_userItem=CCMenuItemSprite::create(userLabel, userLabel, this, menu_selector(SettingsLayer::menuCallback));
m_userItem->setPosition(S_RM->getPositionWithName("setting_acountItem"));
m_userItem->setAnchorPoint(ccp(0,0.5));
this->addMenuItem(m_userItem);
CCLabelTTF* childLabel=CCLabelTTF::create("儿 童:", "", 20);
childLabel->setPosition(S_RM->getPositionWithName("setting_childLabel"));
childLabel->setColor(ccc3(0, 0, 0));
this->addChild(childLabel);
Button9* child=Button9::create("设 置",CCSizeMake(400, 50),20);
CCMenuItemSprite* childItem=CCMenuItemSprite::create(child, child, this, menu_selector(SettingsLayer::menuCallback));
childItem->setPosition(S_RM->getPositionWithName("setting_childItem"));
childItem->setAnchorPoint(ccp(0,0.5));
childItem->setTag(kTagChild);
this->addMenuItem(childItem);
CCLabelTTF* resetLabel=CCLabelTTF::create("学习进度: ", "", 20);
resetLabel->setPosition(S_RM->getPositionWithName("setting_resetLabel"));
resetLabel->setColor(ccc3(0, 0, 0));
this->addChild(resetLabel);
Button9* reset=Button9::create("重 置",CCSizeMake(150, 50),20);
CCMenuItemSprite* resetItem=CCMenuItemSprite::create(reset, reset, this, menu_selector(SettingsLayer::menuCallback));
resetItem->setPosition(S_RM->getPositionWithName("setting_resetItem"));
resetItem->setAnchorPoint(ccp(0,0.5));
resetItem->setTag(kTagReset);
this->addMenuItem(resetItem);
CCLabelTTF* timeLabel=CCLabelTTF::create("时间控制: ", "", 20);
timeLabel->setPosition(S_RM->getPositionWithName("setting_timeLabel"));
timeLabel->setColor(ccc3(0, 0, 0));
this->addChild(timeLabel);
Button9* time=Button9::create("设 置",CCSizeMake(150, 50),20);
CCMenuItemSprite* timeItem=CCMenuItemSprite::create(time, time, this, menu_selector(SettingsLayer::menuCallback));
timeItem->setPosition(S_RM->getPositionWithName("setting_timeItem"));
timeItem->setAnchorPoint(ccp(0,0.5));
timeItem->setTag(kTagTime);
this->addMenuItem(timeItem);
CCLabelTTF* weixinLabel=CCLabelTTF::create("微信绑定:", "", 20);
weixinLabel->setPosition(S_RM->getPositionWithName("setting_weixinLabel"));
weixinLabel->setColor(ccc3(0, 0, 0));
this->addChild(weixinLabel);
Button9* weixin=Button9::create("绑 定",CCSizeMake(150, 50),20);
CCMenuItemSprite* weixinItem=CCMenuItemSprite::create(weixin, weixin, this, menu_selector(SettingsLayer::menuCallback));
weixinItem->setPosition(S_RM->getPositionWithName("setting_weixinItem"));
weixinItem->setAnchorPoint(ccp(0,0.5));
weixinItem->setTag(kTagWeixin);
this->addMenuItem(weixinItem);
#if (CC_TARGET_PLATFORM==CC_PLATFORM_ANDROID)
if (S_UD->getStringForKey("USER_USERNAME", "")=="") {
CCLabelTTF* avatarLabel=CCLabelTTF::create("设置头像: ", "", 20);
avatarLabel->setPosition(S_RM->getPositionWithName("setting_avatarLabel"));
avatarLabel->setColor(ccc3(0, 0, 0));
this->addChild(avatarLabel);
Button9* avatar=Button9::create("设 置",CCSizeMake(150, 50),20);
CCMenuItemSprite* avatarItem=CCMenuItemSprite::create(avatar, avatar, this, menu_selector(SettingsLayer::menuCallback));
avatarItem->setPosition(S_RM->getPositionWithName("setting_avatarItem"));
avatarItem->setAnchorPoint(ccp(0,0.5));
avatarItem->setTag(kTagAvatar);
this->addMenuItem(avatarItem);
}
#endif
//音量开关
CCLabelTTF* volumeLabel=CCLabelTTF::create("音 量:", "", 20);
volumeLabel->setPosition(S_RM->getPositionWithName("setting_volumeLabel"));
volumeLabel->setColor(ccc3(0, 0, 0));
this->addChild(volumeLabel);
CCControlSlider* slider = CCControlSlider::create(CCSprite::createWithSpriteFrameName("volume_3.png"), CCSprite::createWithSpriteFrameName("volume_2.png"), CCSprite::createWithSpriteFrameName("volume_1.png"));
slider->setMinimumValue(0.1f); // Sets the min value of range
slider->setMaximumValue(1.0f); // Sets the max value of range
slider->setPosition(S_RM->getPositionWithName("setting_volumeSlider"));
slider->addTargetWithActionForControlEvents(this, cccontrol_selector(SettingsLayer::volumeValueChanged), CCControlEventValueChanged);
slider->setTag(kTagVolume);
slider->setAnchorPoint(ccp(0,0.5));
this->addChild(slider);
float volume=S_AE->getBackgroundMusicVolume();
slider->setValue(volume);
return true;
}
示例2: 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);
//.........这里部分代码省略.........