本文整理汇总了C++中CCLayerColor类的典型用法代码示例。如果您正苦于以下问题:C++ CCLayerColor类的具体用法?C++ CCLayerColor怎么用?C++ CCLayerColor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CCLayerColor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initTipLayer
bool TipLayer::initTipLayer()
{
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
CCLayerColor *maskLayer = CCLayerColor::node();
maskLayer->initWithColorWidthHeight(ccc4f(0x00,0x00,0x00,0x80),335,350);
//maskLayer->setOpacity(200);
maskLayer->setAnchorPoint(ccp(0.5, 0.5));
maskLayer->setPosition(ccp(winSize.width/2-maskLayer->getContentSize().width/2, winSize.height/2-maskLayer->getContentSize().height/2));
this->addChild(maskLayer);
/*CCSprite *bgSprite = CCSprite::spriteWithFile("actor_pause_bg.png");
this->addChild(bgSprite);
bgSprite->setPosition(ccp(winSize.width / 2, winSize.height / 2));*/
std::string stdNameOne = "";
std::string stdNameTwo = "";
std::string contentImageName = "";
stdNameOne = s_touchfile + s_language + "actor_btn_cancel.png";
stdNameTwo = s_touchfile + s_language + "actor_btn_confirm.png";
contentImageName = s_language + "actor_img_tipContent.png";
//content
CCSprite *pContentSprite = CCSprite::spriteWithFile(contentImageName.c_str());
this->addChild(pContentSprite);
pContentSprite->setPosition(ccp(winSize.width / 2, winSize.height / 2 +100));
CCMenuItemImage *cancelItem = CCMenuItemImage::itemFromNormalImage(stdNameOne.c_str(), stdNameOne.c_str(), this, menu_selector(TipLayer::cancel));
CCMenuItemImage *confirmItem = CCMenuItemImage::itemFromNormalImage(stdNameTwo.c_str(), stdNameTwo.c_str(), this, menu_selector(TipLayer::confirm));
CCMenu *menu = CCMenu::menuWithItems(confirmItem,cancelItem,NULL);
menu->alignItemsVertically();
menu->setPosition(ccp(winSize.width / 2, winSize.height / 2 - 50));
this->addChild(menu);
CCLayer::setIsKeypadEnabled(true);
return true;
}
示例2: ccp
// on "init" you need to initialize your instance
bool TestCleanUp::init()
{
if ( !CCLayer::init() )
{
return false;
}
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
float top = origin.y + visibleSize.height;
CCPoint center = ccp(origin.x + visibleSize.width/2, origin.y + visibleSize.height/2);
// -----
// title
// -------
CCLabelTTF* title = CCLabelTTF::create();
title->setString("Test Clean Up");
title->setPosition(ccp(center.x, top - 50 ));
addChild(title);
{
CCLayerColor* sprite = CCLayerColor::create(ccc4(255,0,0,255));
sprite->changeWidthAndHeight(100, 100);
CCMoveBy* move = CCMoveBy::create(100, ccp(0,0));
sprite->runAction(move);
// check if has memory leak
}
return true;
}
示例3: ccg
//------------------------------------------------------------------
//
// Effect5
//
//------------------------------------------------------------------
void Issue631::onEnter()
{
EffectAdvanceTextLayer::onEnter();
CCActionInterval* effect = (CCActionInterval*)(CCSequence::actions( CCDelayTime::actionWithDuration(2.0f), CCShaky3D::actionWithRange(16, false, ccg(5, 5), 5.0f), NULL));
// cleanup
CCNode* bg = getChildByTag(kTagBackground);
removeChild(bg, true);
// background
CCLayerColor* layer = CCLayerColor::layerWithColor( ccc4(255,0,0,255) );
addChild(layer, -10);
CCSprite* sprite = CCSprite::spriteWithFile("Images/grossini.png");
sprite->setPosition( ccp(50,80) );
layer->addChild(sprite, 10);
// foreground
CCLayerColor* layer2 = CCLayerColor::layerWithColor(ccc4( 0, 255,0,255 ) );
CCSprite* fog = CCSprite::spriteWithFile("Images/Fog.png");
ccBlendFunc bf = {GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA};
fog->setBlendFunc(bf);
layer2->addChild(fog, 1);
addChild(layer2, 1);
layer2->runAction( CCRepeatForever::actionWithAction(effect) );
}
示例4: createListView
void NewsScene::createListView()
{
// CCSize size = CCSize(750, 400);
CCSize size = CCDirector::sharedDirector()->getWinSize();
CCLayerColor * fundo = CCLayerColor::create(ccc4(255, 255, 255, 255), size.width, size.height);
fundo->setAnchorPoint(ccp(0,0));
fundo->setPosition(ccp(0, 0));
this->addChild(fundo,10);
// CCLayerColor * header = CCLayerColor::create(ccc4(200, 200, 200, 255), size.width, 80);
// header->setAnchorPoint(ccp(0,0));
// header->setPosition(ccp(0, size.height -80));
// fundo->addChild(header);
CCSprite *sprHeader;
sprHeader = CCSprite::create("Header_Blue.png");
sprHeader->setAnchorPoint(ccp(0,0));
sprHeader->setScale(1);
sprHeader->setPosition(ccp(0, size.height -90));
this->addChild(sprHeader,100);
CCSprite *sprTitle;
sprTitle = CCSprite::create("tit_informacoes.png");
sprTitle->setAnchorPoint(ccp(0,0));
sprTitle->setScale(1);
sprTitle->setPosition(ccp(110, size.height -50));
this->addChild(sprTitle,101);
CCMenu* menu = CCMenu::create();
CCSprite *spriteDefault = CCSprite::create("Seta1.png");
CCSprite *spriteSelected = CCSprite::create("Seta2.png");
CCMenuItemSprite *item = CCMenuItemSprite::create(spriteDefault, spriteSelected, this, menu_selector(NewsScene::btnBack));
item->setAnchorPoint(ccp(0, 0));
item->setPosition(ccp(0, size.height -90));
menu->addChild(item, 0, 100);
menu->setPosition(ccp(10,30));
menu->setAnchorPoint(ccp(0,0));
this->addChild(menu,102);
list = CCListView::create(CCListViewModeVertical);
list = cocos2d::extension::CCListView::create(CCListViewModeVertical);
list->setDelegate(this);
list->setContentSize(CCSize(size.width, size.height-70));
list->setAnchorPoint(ccp(0,0));
list->setPosition(ccp(0, 0));
list->setColor(ccc3(50, 50, 50));
list->setSeparatorStyle(CCListViewCellSeparatorStyleNone);
fundo->addChild(list);
this->loading = new AnimatedSprite("loader_einstein1.png");
this->loading->addAnimation(AnimatedSprite::animationWithFile("loader_einstein", 24, 0.030f), "anim");//frame_count
this->addChild(this->loading,999);
this->loading->runAnimation("anim",true, true);
this->loading->setAnchorPoint(ccp(0.5f, 0.5f));
this->loading->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width/2, CCDirector::sharedDirector()->getWinSize().height/2 - 30));
this->loading->setVisible(true);
}
示例5: CCSizeMake
//测试只能纵向滚动
void HelloWorld::test2()
{
CCSize visableSize = CCSizeMake(480, 320); //屏幕大小
CCSize mysize = CCSizeMake(150,220); //容器大小
//创建容器、设置大小
CCLayerColor* scrollLayer = CCLayerColor::create( ccc4(255,255,255,255) );
scrollLayer->setContentSize(mysize);
//容器中添加四个按钮
for(int i = 1; i <= 4; i++)
{
char file[20];
sprintf(file, "btn%d.png", i);
CCSprite* btn = CCSprite::create(file);
btn->setPosition( ccp(mysize.width/2, 220 - 50*i) );
scrollLayer->addChild(btn);
}
//创建滚动视图CCScrollView
//可视区域大小150*100 、 容器为scrollLayer
CCScrollView* scrollView = CCScrollView::create(CCSizeMake(150, 100), scrollLayer);
scrollView->setPosition( visableSize/2 - ccp(150/2.0, 100/2.0) );
this->addChild(scrollView, 0, 2);
//设置为只能纵向滚动
scrollView->setDirection(kCCScrollViewDirectionVertical);
//委托代理
scrollView->setDelegate(this);
}
示例6:
bool
WSGameBackGroundLayer::initWithScene(WSGameScene *scene)
{
if (CCLayer::init())
{
CCLayerColor* whiteBg = CCLayerColor::create(ccc4(255, 255, 255, 255), 500, 350);
whiteBg->setAnchorPoint(ccp(0, 0));
whiteBg->setPosition(ccp(320, 170));
this->addChild(whiteBg);
WSMap* map = scene->getGameCore()->getGameMap();
for (int i=0; i<map->getHeight(); i++) {
for (int j=0; j<map->getWidth(); j++) {
if (map->getMapNodeByXY(j, i) == kEdge)
{
CCSprite* sprite = CCSprite::create("edge.png");
sprite->setAnchorPoint(ccp(0, 0));
sprite->setPosition(ccp(320+ j*sprite->boundingBox().size.width, 170 + (map->getHeight()-i-1)*sprite->boundingBox().size.height));
this->addChild(sprite);
}
}
}
return true;
}
return false;
}
示例7: AchievementSystem
void AchievementLayer::updateAchievement(AchievementUpdateType type) {
if (_achievementAchievementsLayer != NULL)
_achievementAchievementsLayer->removeFromParentAndCleanup(true);
_type = type;
std::vector<CCNode*> nodes;
//we have to create a variable with the AchievementSystem
//otherwise it will delete the content of the vector
AchievementSystem achSys = AchievementSystem();
std::vector<Achievement*> achievements = achSys.getAchievements();
float achievement_width = 0;
for (std::vector<Achievement*>::iterator achi = achievements.begin(); achi != achievements.end(); ++achi) {
if (type == AUT_ACHIEVED && !(*achi)->isAchieved())
continue;
else if (type == AUT_NOT_ACHIEVED && (*achi)->isAchieved())
continue;
CCLayerColor* ach = ViewTools::createLayerFromAchievement(*achi);
nodes.push_back(ach);
if (achievement_width == 0) {
achievement_width = ach->getContentSize().width;
}
}
float scale = Model::getInstance()->getGUIElementScaleMultiplicator();
float percent = (float) achSys.getPoints() / (float) achSys.getMaxPoints() * 100;
std::string title = "Score: " + Tools::toString(achSys.getPoints()) + " (" + Tools::toString((int) percent) + "%)";
_achievementAchievementsLayer = ScrollLayer::create(title.c_str(), nodes, achievement_width, 10 * scale);
getParent()->addChild(_achievementAchievementsLayer);
}
示例8:
void LevelGame05::pauseCallback(CCObject *pSender)
{
CCSize size = CCDirector::sharedDirector()->getWinSize();
CCLayerColor *layer = CCLayerColor::create(ccc4(0, 0, 0, 200), size.width, size.height);
layer->setTag(80);
CCMenu *pmenu=(CCMenu *)getChildByTag(100);//9¸ö²Ëµ¥Ïî½ûÖ¹
pmenu->setEnabled(false);
CCMenu *pause=(CCMenu *)getChildByTag(101);//101ÊÇÔÝÍ£ÔٴνûÖ¹
pause->setEnabled(false);
CCSprite *sp =CCSprite::createWithSpriteFrameName("bg.png");
sp->setPosition(CCPoint(size.width*0.5, size.height*0.5));
layer->addChild(sp);
CCSpriteFrameCache *cache = CCSpriteFrameCache::sharedSpriteFrameCache();
CCMenuItemImage *closeItem = CCMenuItemImage::create();
closeItem->setNormalSpriteFrame(cache->spriteFrameByName("back-1.png"));
closeItem->setSelectedSpriteFrame(cache->spriteFrameByName("back-2.png"));
closeItem->initWithTarget(this, menu_selector(LevelGame05::menuCloseCallback));
closeItem->setPosition(CCPoint(size.width*0.1,80));
CCMenu *menus = CCMenu::create(closeItem, NULL);
menus->setPosition(CCPointZero);
layer->addChild(menus);
CCMenuItemImage *Item1 = CCMenuItemImage::create();
Item1->setNormalSpriteFrame(cache->spriteFrameByName("home-1.png"));
Item1->setSelectedSpriteFrame(cache->spriteFrameByName("home-2.png"));
Item1->initWithTarget(this,menu_selector(LevelGame05::homeCallback));
Item1->setPosition(ccp(size.width*0.5-300, size.height*0.5));
Item1->setTag(125);
CCMenuItemImage *Item2 = CCMenuItemImage::create();
Item2->setNormalSpriteFrame(cache->spriteFrameByName("pause-list-1.png"));
Item2->setSelectedSpriteFrame(cache->spriteFrameByName("pause-list-2.png"));
Item2->initWithTarget(this,menu_selector(LevelGame05::winloseCallback));
Item2->setPosition(ccp(size.width*0.5, size.height*0.5));
Item2->setTag(126);
CCMenuItemImage *Item3 = CCMenuItemImage::create();
if(isMusic == true)
{
Item3->setNormalSpriteFrame(cache->spriteFrameByName("pause-music.png"));
// Item3->setSelectedSpriteFrame(cache->spriteFrameByName("close-pause-music.png"));
}
else
{
Item3->setNormalSpriteFrame(cache->spriteFrameByName("close-pause-music.png"));
//Item3->setSelectedSpriteFrame(cache->spriteFrameByName("pause-music.png"));
}
Item3->initWithTarget(this,menu_selector(LevelGame05::musicCallback));
Item3->setPosition(ccp(size.width*0.5+300, size.height*0.5));
Item3->setTag(127);
CCMenu* menu= CCMenu::create(Item1,Item2,Item3, NULL);
menu->setPosition(CCPointZero);
menu->setTag(128);
layer->addChild(menu);
this->addChild(layer,2);
}
示例9: Load
void HSLoadingLayer::Load()
{
CCLayerColor* pMaskLayer = CCLayerColor::create(ccc4(0, 0, 0, 200),
HSBase::GetTemplateScreenW() + 10.f, HSBase::GetTemplateScreenH());
pMaskLayer->setAnchorPoint(HS_ANCHOR_CENTER);
this->addChild(pMaskLayer);
pMaskLayer->setPosition(ccp(-2.f,0));
HSToolBase::SetNodeFilldScreen(pMaskLayer);
// void *bigmem=malloc(1048576*5);
/**
CCSprite* pLoadingSprite = HSCCSprite::create("Image/LODADING.png");
pLoadingSprite->setPosition(HSBase::GetTemplateScreenCentre());
this->addChild(pLoadingSprite);*/
/**
CCSprite* pMaskSprite = HSCCSprite::create("Image/LODADINGzhezhao.png");
pMaskSprite->setOpacity(255 - 153);
m_pProgressTimeer = CCProgressTimer::create(pMaskSprite);
m_pProgressTimeer->setType(kCCProgressTimerTypeBar);
m_pProgressTimeer->setMidpoint(ccp(0,0));
m_pProgressTimeer->setBarChangeRate(ccp(1, 0));
m_pProgressTimeer->setPosition(pLoadingSprite->getPosition());
this->addChild(m_pProgressTimeer);
m_pProgressTimeer->setReverseProgress(true);
*/
if (1)
{
m_pTipsTTFUp = CCLabelTTF::create("",HS_FONT_HuaKang, 38.f, CCSizeMake(500,960),
kCCTextAlignmentCenter, kCCVerticalTextAlignmentCenter);
m_pTipsTTFUp->setPosition(ccp(320.f,800.f));
this->addChild(m_pTipsTTFUp);
CCString* pTipsStr = CCString::createWithFormat("tips_%d",
HSMath::Random(0, 19));
m_pTipsTTF = CCLabelTTF::create(L(pTipsStr->getCString()),
HS_FONT_HuaKang, 32.f, CCSizeMake(500,960),
kCCTextAlignmentCenter, kCCVerticalTextAlignmentCenter);
//m_pTipsTTF->setPosition(HSBase::GetTemplateScreenCentre());
m_pTipsTTF->setPosition(
/*ccp(HSBase::GetTemplateScreenW() / 2.f,pLoadingSprite->getContentSize().height)*/ccp(320.f,180.f));
this->addChild(m_pTipsTTF);
//m_pTipsTTF->getString();
}
// m_backSprite = HSCCSprite::create("Image/lodingback.png");
// m_backSprite->setPosition(ccp(320.f,340.f));
// this->addChild(m_backSprite);
m_pSpxLoading = SPX_Manager::CreateSprite("SPX/cat.sprite");
m_pSpxLoading->setPosition(ccp(320.f,306.f));
m_pSpxLoading->SetAction(0);
this->addChild(m_pSpxLoading);
this->setVisible(false);
}
示例10: init
bool LoginLayerUC::init()
{
BaseLayer::init();
m_ui = nullptr;
m_iCurrentType = LoginResponseMsg;
m_LayoutRoot = CWidgetWindow::create();
m_LayoutRoot->setTag(10000);
this->addChild(m_LayoutRoot);
CCLayerColor* pColor = CCLayerColor::create(ccc4(255, 255, 255, 255));
pColor->setContentSize(WINSIZE);
pColor->setPosition(CCPointZero);
m_LayoutRoot->addChild(pColor, -1);
//加载
CCArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo("loginScene/opening.ExportJson");
//生成骨骼
m_armature = CCArmature::create("opening");
m_armature->setPosition(VCENTER);
m_LayoutRoot->addChild(m_armature);
//绑定动画事件
m_armature->getAnimation()->setMovementEventCallFunc(this, movementEvent_selector(LoginLayerUC::movementCallBack));
m_armature->getAnimation()->setFrameEventCallFunc(this, frameEvent_selector(LoginLayerUC::frameEventCallBack));
m_armature->getAnimation()->playWithIndex(0);
this->runAction(CCSequence::createWithTwoActions(CCDelayTime::create(2.8f), CCCallFunc::create(this, callfunc_selector(LoginLayerUC::callBackForSoundUp))));
return true;
}
示例11: setUpTopImage
ParkingViewScene::ParkingViewScene(EstacionamentoState _state, int _wayPointID)
{
isChangeToRoute = false;
plistTagMenuCurrent.clear();
plistMenuCurrent.clear();
setUpTopImage(Global::TOP_SRC_IMAGE_Estacionamentos);
ChangeTitle(ESTACIOMENTOS);
this->addButtonTop();
//initFixedMenu();
this->wayPointID = _wayPointID;
this->state=_state;
if( state == EST_SAIDA)
{
actualCategory = ESTACIOMENTOS;
CCLayerColor *node = CCLayerColor::create(ccc4(0,0,0,0));
node->setAnchorPoint(ccp(0,0));
node->setPosition(ccp(0,0));
this->addChild(node,0, 250);
//Carrega informacoes do Estacionamento ( semelhante waypointID
LoadParkingId();
}
else
{
//Isso e so exibido quando o usuario esta na entrada
if( wayPointID == 51)
//Exibe uma mensagem de alerta configurada para estacionamentos
AlertViewScene::showMessageParking( this,menu_selector(ParkingViewScene::btnResponse),250);
else
//Exibe o mapa do Google Maps
this->addChild(new LayerWebView(wayPointID));
}
}
示例12:
void T27ActionMore::ccTouchEnded(CCTouch* t, CCEvent*)
{
CCPoint ptStart = t->getStartLocation();
CCPoint ptEnd = t->getLocation();
if (ptStart.getDistanceSq(ptEnd) <= 25)
{
// click
// 点中了哪个子窗口
// 转换ptStart为ScrollView中的Container的坐标
// 再判断被点击的LayerColor
CCPoint ptInContainer = _c->convertToNodeSpace(ptStart);
CCArray* arr = _c->getChildren(); // 所有的layercolor
for (int i = 0; i < sizeof(_actionName) / sizeof(*_actionName); i++)
{
CCLayerColor* layer = (CCLayerColor*)arr->objectAtIndex(i);
if (layer->boundingBox().containsPoint(ptInContainer))
{
testAction(i, layer);
break;
}
}
}
}
示例13: addChild
void SpriteDemo::onEnter()
{
CCLayer::onEnter();
CCSize s = CCDirector::sharedDirector()->getWinSize();
CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Arial", 18);
addChild(label, 1);
label->setPosition( ccp(s.width/2, s.height-50) );
std::string strSubtitle = subtitle();
if( ! strSubtitle.empty() )
{
CCLabelTTF* l = CCLabelTTF::create(strSubtitle.c_str(), "Thonburi", 22);
addChild(l, 1);
l->setPosition( ccp(s.width/2, s.height-80) );
}
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(SpriteDemo::backCallback) );
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(SpriteDemo::restartCallback) );
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(SpriteDemo::nextCallback) );
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
menu->setPosition(CCPointZero);
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
addChild(menu, 1);
CCLayerColor *background = CCLayerColor::create(ccc4(255,0,0,255));
background->setPosition(ccp(s.width/2,s.height/2));
addChild(background, -10);
}
示例14: removeChild
void LevelGame05::gamewin(float dt)
{
if(isMusic == true)
{
SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
SimpleAudioEngine::sharedEngine()->playEffect("win.wav");
/*scheduleOnce(schedule_selector(LevelGame05::updateMusic),2.5f);*/
/* SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();*/
}
CCSprite* sprite=(CCSprite *)getChildByTag(90);
sprite->setVisible(false);
CCLayerColor *layerc =(CCLayerColor *)getChildByTag(80);
removeChild(layerc,true);
CCMenu *pmenu=(CCMenu *)getChildByTag(100);//yi_normal½ûÖ¹
pmenu->setVisible(true);
CCMenu *pause=(CCMenu *)getChildByTag(101);//105ÊÇÔÝÍ£ÔٴνûÖ¹
pause->setVisible(true);
CCMenu *pause1=(CCMenu *)getChildByTag(101);//105ÊÇÔÝÍ£½ûÖ¹
pause1->setEnabled(false);
CCSize size = CCDirector::sharedDirector()->getWinSize();
CCLayerColor *layer = CCLayerColor::create(ccc4(0, 0, 0, 200), size.width, size.height);
CCSprite *sp =CCSprite::create("bg-5-win.png");
sp->setPosition(CCPoint(size.width*0.5, size.height*0.5));
layer->addChild(sp);
//CCSprite* win_smile =CCSprite::createWithSpriteFrameName("win-smile.png");
// win_smile->setPosition(CCPoint(size.width*0.5-300,size.height*0.5));
//layer->addChild(win_smile);
CCSpriteFrameCache *cache = CCSpriteFrameCache::sharedSpriteFrameCache();
CCMenuItemImage *Item1 = CCMenuItemImage::create();
Item1->setNormalSpriteFrame(cache->spriteFrameByName("win-lose-list-1.png"));
Item1->setSelectedSpriteFrame(cache->spriteFrameByName("win-lose-list-2.png"));
Item1->initWithTarget(this,menu_selector(LevelGame05::winloseCallback));
Item1->setPosition(ccp(size.width*0.5-150, size.height*0.5-50));
Item1->setTag(120);
CCMenuItemImage *Item2 = CCMenuItemImage::create();
Item2->setNormalSpriteFrame(cache->spriteFrameByName("result-1.png"));
Item2->setSelectedSpriteFrame(cache->spriteFrameByName("result-2.png"));
Item2->initWithTarget(this,menu_selector(LevelGame05::resultCallback));
Item2->setPosition(ccp(size.width*0.5+100, size.height*0.5-50));
Item2->setTag(121);
CCMenuItemImage *Item3 = CCMenuItemImage::create();
Item3->setNormalSpriteFrame(cache->spriteFrameByName("next-1.png"));
Item3->setSelectedSpriteFrame(cache->spriteFrameByName("next-2.png"));
Item3->initWithTarget(this,menu_selector(LevelGame05::nextCallback));
Item3->setPosition(ccp(size.width*0.5+350, size.height*0.5-50));
Item3->setTag(122);
CCMenu* menu= CCMenu::create(Item1,Item2,Item3, NULL);
menu->setPosition(CCPointZero);
menu->setTag(123);
layer->addChild(menu);
this->addChild(layer,3);
}
示例15: addChild
bool LayerSetup::init()
{
CCLayer::init();
CCLayerColor* layerTrans = CCLayerColor::create(ccc4(192, 192, 192, 128));
addChild(layerTrans);
CCLayerColor* layerBG = CCLayerColor::create(ccc4(192, 192, 192, 255), winSize.width / 2, winSize.height / 2);
addChild(layerBG);
layerBG->setPosition(ccp(winSize.width / 4, winSize.height / 4));
// 创建两个slider
MyCCControlSlider* volumeBG = MyCCControlSlider::create("sliderTrack.png", "sliderProgress.png", "sliderThumb.png");
MyCCControlSlider* volumeEffect = MyCCControlSlider::create("sliderTrack.png", "sliderProgress.png", "sliderThumb.png");
addChild(volumeBG);
addChild(volumeEffect);
_volumeBG = volumeBG;
_volumeEffect = volumeEffect;
volumeBG->setMinimumValue(0.0f);
volumeBG->setMaximumValue(1.0f);
volumeEffect->setMinimumValue(0.0f);
volumeEffect->setMaximumValue(1.0f);
volumeBG->setPosition(ccp(winSize.width / 2, winSize.height / 2));
volumeEffect->setPosition(ccp(winSize.width / 2, winSize.height / 2));
Common::moveNodeY(volumeBG, 40);
// Common::moveNodeY(volumeEffect, -30);
volumeBG->addTargetWithActionForControlEvents(this, cccontrol_selector(LayerSetup::ChangeBGVolume), CCControlEventValueChanged);
volumeEffect->addTargetWithActionForControlEvents(this, cccontrol_selector(LayerSetup::ChangeEffectVolume), CCControlEventValueChanged);
setZOrder(Common::ZO_LAYER_SETUP);
// 读配置文件
float fVolumeBG = CCUserDefault::sharedUserDefault()->getFloatForKey("BGVolume", 1.0f);
float fVolumeEffect = CCUserDefault::sharedUserDefault()->getFloatForKey("EffectVolume", 1.0f);
volumeBG->setValue(fVolumeBG);
volumeEffect->setValue(fVolumeEffect);
// 创建一个确定按钮
CCMenuItemFont* item = CCMenuItemFont::create("Close", this, menu_selector(LayerSetup::Close));
CCMenu* menu = CCMenu::createWithItem(item);
addChild(menu);
Common::moveNode(item, ccp(80, -60));
_menu = menu;
// 暂停
// CCDirector::sharedDirector()->pause();
setTouchEnabled(true);
setTouchMode(kCCTouchesOneByOne);
setTouchPriority(-130);
return true;
}