Example #1
0
void RankScene::enableButtons(){
    if (tableIndex == 1) {
        bottomMenu->setTouchEnabled(true);
    }
    if (tableIndex == 2) {
        chooseMenu->setTouchEnabled(true);
        bottomMenu->setTouchEnabled(true);
    }
    if (tableIndex == 3) {
        buyMenu->setTouchEnabled(true); //道具
        backMenu->setTouchEnabled(true); //返回
        //金币旁边的加号
    }
    LevelUpMenu->setTouchEnabled(true);
    moveMenu->setTouchEnabled(true);
    beginMenu->setTouchEnabled(true);
    if (LevelUpLayerHasBeenOpened)
        LevelUpMenuDetail->setTouchEnabled(true);
    CCMenu* goldMenu = (CCMenu*)this->getChildByTag(17); //购买金币
    CCMenu* bottomMenu = (CCMenu*)layerToRoll->getChildByTag(10); //下面的四个按钮
    CCMenu* leftAndRightMenu = (CCMenu*)this->getChildByTag(3);  //左右滑动
    goldMenu->setTouchEnabled(true);
    bottomMenu->setTouchEnabled(true);
    leftAndRightMenu->setTouchEnabled(true);
}
Example #2
0
void HTouchEnabledLayerColor::setPriority(CCNode *node, int priority) {
    if (dynamic_cast<CCControl *>(node)) {
        CCControl *control = (CCControl *)node;
        control->setTouchPriority(priority);
        if (control->isTouchEnabled()) {
            control->setTouchEnabled(false);
            control->setTouchEnabled(true);
        }
    } else if (dynamic_cast<CCScrollView *>(node)) {
        CCScrollView *scrollView = (CCScrollView *)node;
        scrollView->setTouchPriority(priority);
        if (scrollView->isTouchEnabled()) {
            scrollView->setTouchEnabled(false);
            scrollView->setTouchEnabled(true);
        }
    } else if (dynamic_cast<CCMenu *>(node)) {
        CCMenu *menu = (CCMenu *)node;
        menu->setTouchPriority(priority);
        if (menu->isTouchEnabled()) {
            menu->setTouchEnabled(false);
            menu->setTouchEnabled(true);
        }
    } else if (dynamic_cast<CCLayer *>(node)) {
        CCLayer *layer = (CCLayer *)node;
        layer->setTouchPriority(priority);
        if (layer->isTouchEnabled()) {
            layer->setTouchEnabled(false);
            layer->setTouchEnabled(true);
        }
    }
}
Example #3
0
void BugsTest::issue1410v2MenuCallback(cocos2d::CCObject *pSender)
{
    CCMenu *menu = (CCMenu*)((CCMenuItem*)pSender)->getParent();
    menu->setTouchEnabled(true);
    menu->setTouchEnabled(false);
    
    CCLog("NO CRASHES. AND MENU SHOULD STOP WORKING");
}
Example #4
0
void LogInScene::closeLogInTable(){
    CCMenu* popUpMenu = (CCMenu*)popUpMenuLayer->getChildByTag(998);
    CCMenu* beginMenu = (CCMenu*)this->getChildByTag(997);
    if(beginMenu!=NULL)
        beginMenu->setTouchEnabled(true);
    popUpMenu->setTouchEnabled(true);

    removeChild(AccountLayer);
}
Example #5
0
CCObject *HTouchEnabledLayerColor::updatePriorityEx(int command, CCNode *node) {
    int iBasePriority = getTouchPriority();
    
    if (dynamic_cast<CCControl *>(node)) {
        CCControl *control = (CCControl *)node;
        int priority = control->getTouchPriority();
        priority = iBasePriority - 9;
        control->setTouchPriority(priority);
        if (control->isTouchEnabled()) {
            control->setTouchEnabled(false);
            control->setTouchEnabled(true);
        }
    } else if (dynamic_cast<CCScrollView *>(node)) {
        CCScrollView *scrollView = (CCScrollView *)node;
        int priority = scrollView->getTouchPriority();
        priority = iBasePriority - 11;
        scrollView->setTouchPriority(priority);
        if (scrollView->isTouchEnabled()) {
            scrollView->setTouchEnabled(false);
            scrollView->setTouchEnabled(true);
        }
    } else if (dynamic_cast<CCMenu *>(node)) {
        CCMenu *menu = (CCMenu *)node;
        int priority = menu->getTouchPriority();
        priority = iBasePriority - 128;
        menu->setTouchPriority(priority);
        if (menu->isTouchEnabled()) {
            menu->setTouchEnabled(false);
            menu->setTouchEnabled(true);
        }
    } else if (dynamic_cast<CCLayer *>(node)) {
        CCLayer *layer = (CCLayer *)node;
        int priority = layer->getTouchPriority();
        priority = iBasePriority;
        layer->setTouchPriority(priority);
        if (layer->isTouchEnabled()) {
            layer->setTouchEnabled(false);
            layer->setTouchEnabled(true);
        }
    }

    CCArray *children = node->getChildren();
    if (children) {
        int count = children->count();
        for (int i = 0; i < count; ++i) {
            CCNode *child = (CCNode *)children->objectAtIndex(i);
            updatePriorityEx(command, child);
        }
    }
    
    return NULL;
}
Example #6
0
void SGVisitItem1::setIsCanTouch(bool touch)
{
    CCMenu *menu = (CCMenu *)this->getChildByTag(111);
    if (menu) {
        menu->setTouchEnabled(touch);
    }
}
Example #7
0
void ASGame::changeHeart(int _shengming,int _source){
    
    shengming += _shengming;
    if (shengming<=0)
        shengming = 0;
    
    //1.血条
    CCProgressTimer* heartBar = (CCProgressTimer*)this->getChildByTag(1*10000000+2222);
    CCProgressFromTo* action = CCProgressFromTo::create(0.5, heartBar->getPercentage(), (float)shengming/(float)maxShengMing*100);
    heartBar->runAction(action);
    if ((float)shengming <= 0.4*(float)maxShengMing){
        heartBar->getSprite()->setColor(ccc3(237, 45, 37));
        
        if(!MainUser->muted){
            CocosDenshion::SimpleAudioEngine::sharedEngine()->stopEffect(heartSoundEffect);
            heartSoundEffect = CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("noHeart.wav", true);
        }
    }else{
        heartBar->getSprite()->setColor(ccc3(255, 255, 255));
        if(!MainUser->muted)
            CocosDenshion::SimpleAudioEngine::sharedEngine()->stopEffect(heartSoundEffect);
    }
    
    //2.生命数字
    string HeartStr = int2string(shengming)  + "/" + int2string(maxShengMing);
    CCLabelTTF* heartLabel = (CCLabelTTF*)this->getChildByTag(playerNumber*10000000+2223);
    heartLabel->setString(HeartStr.c_str());

    //3.判断胜利条件
    if (shengming == 0 && !((GameBaseClass*)getParent())->gameover){
        ((GameBaseClass*)getParent())->gameover = true;
        //1.禁用各种按钮
        CCMenu* skillMenu = (CCMenu*)this->getChildByTag(1*10000000+27);
        CCMenu* optionMenu = (CCMenu*)this->getChildByTag(1*10000000+12);
        CCMenu* itemMenu = (CCMenu*)this->getChildByTag(1*10000000+77776);
        skillMenu->setTouchEnabled(false);
        optionMenu->setTouchEnabled(false);
        itemMenu->setTouchEnabled(false);
        
        //2.停止所有监听
        unscheduleAllSelectors();
        bot2->unscheduleAllSelectors();
        
        //3.结束页面
        ((GameBaseClass*)getParent())->GameResult(1);
    }
}
void UserInterface::Prepare() {
    CCLabelTTF *label = CCLabelTTF::create("Light ON/OFF", "HelveticaNeue-Bold", 25);
    CCMenuItemLabel *labelItem = CCMenuItemLabel::create(label, (CCObject *)engine, menu_selector(TEEngine::switchLight));
    ccColor3B color = {255, 255, 255};
    labelItem->setColor(color);
    labelItem->setPosition(CCPointZero);
    labelItem->setAnchorPoint(CCPointZero);
    CCMenu *menu = CCMenu::create(labelItem, nullptr);
    menu->setPosition(CCPoint(00, 560));
    menu->setTouchEnabled(true);
    _guiNodes->addObject(menu);
    
}
Example #9
0
void ASGame::energyBarAnimation(){
    
    //1.显示行动力的圆形底座
    CCSprite* energyBall = CCSprite::createWithSpriteFrameName("newEnergyContainer.png");
    energyBall->setPosition(ccp(size.width*17.38/80,size.height*77.85/90+winDif*2*alpha*alpha));
    addChild(energyBall,4);
    
    //2.行动力数量
    string perStr = int2string(moveCount);
    CCLabelTTF* per = CCLabelTTF::create(perStr.c_str(),"Arial Rounded MT bold",32);
    per->setPosition(ccp(size.width*17.38/80,size.height*77.85/90+winDif*2*alpha*alpha));
    addChild(per,5,1*10000000+26);
    
    //3.能量条
    CCSprite* energyBarSprite = CCSprite::createWithSpriteFrameName("newEnergyBar.png");
    CCProgressTimer* energyBar = CCProgressTimer::create(energyBarSprite);
    energyBar->setPosition(ccp(size.width*8.45/80,size.height*79.89/90+winDif*2*alpha*alpha));
    energyBar->setType(kCCProgressTimerTypeRadial);
    energyBar->setPercentage(moveCount*20);
    addChild(energyBar,4,1*10000000+20);
    
    //4.攻击按钮底座
    CCSprite* containerSprite = CCSprite::createWithSpriteFrameName("energyContainer.png");
    CCSprite* containerSprite_s = CCSprite::createWithSpriteFrameName("energyContainer.png");
    CCMenuItemSprite* energyContainer = CCMenuItemSprite::create(containerSprite,containerSprite_s,this,menu_selector(ASGame::enterFightLayer));
    energyContainer->setScale(1.05);
    energyContainer->setPosition(ccp(size.width*179.5/200,size.height*10.25/135));
    CCMenu* energyContainerMenu = CCMenu::create(energyContainer,NULL);
    energyContainerMenu->setPosition(CCPointZero);
    if (moveCount < moveToFight)
            energyContainerMenu->setTouchEnabled(false);
    addChild(energyContainerMenu,2,1*10000000+27);
    
    //5.攻击按钮充值槽
    CCSprite* barSprite = CCSprite::createWithSpriteFrameName("energyBar.png");
    CCProgressTimer* attackButton = CCProgressTimer::create(barSprite);
    attackButton->setScale(1.05);
    attackButton->setPosition(ccp(size.width*179.04/200,size.height*10/135));
    attackButton->setType(kCCProgressTimerTypeBar);
    attackButton->setMidpoint(ccp(0.5, 0));
    attackButton->setBarChangeRate(ccp(0, 1));
    attackButton->setPercentage(100*moveCount/moveToFight);
    addChild(attackButton,3,1*10000000+25);
    
    //4.能量的盖子
    CCSprite* energyBarCover = CCSprite::createWithSpriteFrameName("energyBarCover.png");
    energyBarCover->setPosition(ccp(size.width*179.5/200,size.height*10.25/135));
    energyBarCover->setOpacity(0);
    //addChild(energyBarCover,4,1*10000000+28);
}
Example #10
0
void LogInScene::LogInTableDraw(int _index){
    
    CCMenu* popUpMenu = (CCMenu*)popUpMenuLayer->getChildByTag(998);
    CCMenu* beginMenu = (CCMenu*)this->getChildByTag(997);
    popUpMenu->setTouchEnabled(false);
    if (beginMenu!=NULL)
        beginMenu->setTouchEnabled(false);
    
    //1.基本层
    AccountLayer = CCLayer::create();
    AccountLayer->setPosition(CCPointZero);
    addChild(AccountLayer,10);
    
    //2.黑色遮罩:不在该移动层上
    CCLayerColor* black = CCLayerColor::create(ccc4(0, 0, 0, 155));
    black->setPosition(CCPointZero);
    AccountLayer->addChild(black,0);
    
    //3.木板
    CCSprite* LogInTable = CCSprite::createWithSpriteFrameName("LogInTable.png");
    LogInTable->setPosition(ccp(size.width/2, size.height/2+winDif*2));
    AccountLayer->addChild(LogInTable,1);
    
    //3.edit box - user name
    CCScale9Sprite *UserNameTexture = CCScale9Sprite::createWithSpriteFrameName("textTable.png");
    CCEditBox *UserNameBox=CCEditBox::create(CCSizeMake(195, 44), UserNameTexture);
    UserNameBox->setPosition(ccp(size.width*8/15, size.height*0.561+winDif*2));
    UserNameBox->setFontName("Arial Rounded MT bold");
    UserNameBox->setMaxLength(20);
    UserNameBox->setInputMode(kEditBoxInputModeAny);
    UserNameBox->setInputFlag(kEditBoxInputFlagSensitive);
    UserNameBox->setReturnType(kKeyboardReturnTypeDone);
    UserNameBox->setDelegate(this);
    AccountLayer->addChild(UserNameBox,2,10);
    
    //4.edit box - password
    CCScale9Sprite *PasswordTexture = CCScale9Sprite::createWithSpriteFrameName("textTable.png");
    CCEditBox *PasswordBox = CCEditBox::create(CCSizeMake(195, 44), PasswordTexture);
    PasswordBox->setPosition(ccp(size.width*8/15, size.height*0.486+winDif*2));
    PasswordBox->setFontName("Arial Rounded MT bold");
    PasswordBox->setMaxLength(50);
    PasswordBox->setInputMode(kEditBoxInputModeAny);
    PasswordBox->setInputFlag(kEditBoxInputFlagPassword);
    PasswordBox->setReturnType(kKeyboardReturnTypeDone);
    PasswordBox->setDelegate(this);
    AccountLayer->addChild(PasswordBox,2,11);
    
    //5.登录注册按钮
    CCMenuItemSprite* Item1;
    if (_index == 0){
        CCSprite* item1Sprite = CCSprite::createWithSpriteFrameName("signUpButtonGreen.png");
        CCSprite* item1Sprite_s = CCSprite::createWithSpriteFrameName("signUpButtonGreen-s.png");
        Item1 = CCMenuItemSprite::create(item1Sprite,item1Sprite_s,this,menu_selector(LogInScene::SignUpHTTP));
    }
    else if (_index == 1){
        CCSprite* item1Sprite = CCSprite::createWithSpriteFrameName("binding.png");
        CCSprite* item1Sprite_s = CCSprite::createWithSpriteFrameName("binding-s.png");
        Item1 = CCMenuItemSprite::create(item1Sprite,item1Sprite_s,this,menu_selector(LogInScene::bindUserAccountHTTP));
    }
    else if (_index == 2){
        CCSprite* item1Sprite = CCSprite::createWithSpriteFrameName("LogInButton.png");
        CCSprite* item1Sprite_s = CCSprite::createWithSpriteFrameName("LogInButton-s.png");
        Item1 = CCMenuItemSprite::create(item1Sprite,item1Sprite_s,this,menu_selector(LogInScene::LogInHTTP));
    }
    CCSprite* item2Sprite = CCSprite::createWithSpriteFrameName("cancelButton.png");
    CCSprite* item2Sprite_s = CCSprite::createWithSpriteFrameName("cancelButton-s.png");
    CCMenuItemSprite* Item2 = CCMenuItemSprite::create(item2Sprite,item2Sprite_s,this,menu_selector(LogInScene::closeThisLayer));
    Item1->setPosition(ccp(winSize.width*11.5/30,size.height*0.42+winDif*2));
    Item2->setPosition(ccp(winSize.width*18.5/30,size.height*0.42+winDif*2));
    CCMenu* LogInMenu = CCMenu::create(Item1,Item2,NULL);
    LogInMenu->setPosition(CCPointZero);
    AccountLayer->addChild(LogInMenu,3);
}