Example #1
0
void QimiAlipayView::changePrie()
{
    std::string p = m_pEditName->getText();
    int price = atoi(p.c_str());
    for (int i =0; i < m_pButtonList->count() ; i++) {
        CCControlButton* b = dynamic_cast<CCControlButton*>(m_pButtonList->objectAtIndex(i));
        b->setEnabled(true);
    }
    CCControlButton* btn = dynamic_cast<CCControlButton*>(this->getChildByTag(100)->getChildByTag(price));
    if (btn!=NULL)
    {
        btn->setEnabled(false);
    }
    upDataView(price);
}
Example #2
0
void QimiAlipayView::upSelectState(CCControlButton* btn)
{
    for (int i =0; i < m_pButtonList->count(); i++) {
        CCControlButton* b = dynamic_cast<CCControlButton* >(m_pButtonList->objectAtIndex(i));
        if (b == btn)
        {
            b->setEnabled(false);
            b->setTitleColorForState(ccc3(255, 255, 255), CCControlStateDisabled);
        }
        else
        {
            b->setEnabled(true);
        }
    }
}
void QuestionLayer::touchDownAction(CCObject *sender, CCControlEvent controlEvent)
{
    CCLOG("QuestionLayer::touchDownAction");

    if (isAnswerFinished) {
        return;
    }
    this->unschedule(schedule_selector(QuestionLayer::timerCB));

    CCControlButton* button = (CCControlButton *)sender;
    CCLOG("%d", button->getTag());
    button->setEnabled(false);

    bool bFind = false;
    CCDictionary* results = questionObj->rightAnswer;
    for (int i=0; i<results->allKeys()->count(); i++) {
        CCString* key = (CCString *)(results->allKeys()->objectAtIndex(i));
        if (key->intValue() == button->getTag()) {
            results->setObject(CCString::createWithFormat("%d", 1), key->getCString());
            bFind = true;
            break;
        }
    }

    if (bFind) {
        //统计已经回答正确答案的数量
        int rCount = 0;
        for (int i=0; i<results->allKeys()->count(); i++) {
            CCString* key = (CCString *)(results->allKeys()->objectAtIndex(i));
            CCString* value = (CCString *)(results->objectForKey(key->getCString()));
            if (value->intValue() == 1) {
                rCount++;
            }
        }
        CCLOG("rCount:%d", rCount);

        if (rCount == results->allKeys()->count()) {
            //回答完成所有正确答案
            for (int i=0; i<results->allKeys()->count(); i++) {
                CCString* key = (CCString *)(results->allKeys()->objectAtIndex(i));
                CCControlButton* btn = (CCControlButton *)(this->getChildByTag(key->intValue()));
                CCSprite* spr = CCSprite::create("star000.png");
                spr->setAnchorPoint(ccp(0.5f, 0.5f));
                spr->setPosition(ccp(button->getContentSize().width/2, button->getContentSize().height/2));
                btn->addChild(spr);
                CCBlink* blink = CCBlink::create(1.0f, 3);
                if (i < results->allKeys()->count()-1) {
                    spr->runAction(blink);
                } else {
                    CCAction* pAction = CCCallFuncND::create(this, callfuncND_selector(QuestionLayer::noticeDelegate), NULL);
                    spr->runAction(CCSequence::create(blink, pAction, NULL));
                }
            }

            rightAnswer++;
            if (timerCount >= timerTotal*2/3) {
                rightLimit += 1;
                //播放快速答题音效
                GameSoundManager::shareManager()->playAnswerCool();
            } else {
                //播放普通答题正确音效
                GameSoundManager::shareManager()->playAnswerRight();
            }

            isAnswerFinished = true;

        } else {
            CCLOG("正确答案没选完");
        }
    } else {
        //回答错误
        CCSprite* spr = CCSprite::create("arrow000.png");
        spr->setAnchorPoint(ccp(0.5f, 0.5f));
        spr->setPosition(ccp(button->getContentSize().width/2, button->getContentSize().height/2));
        button->addChild(spr);
        CCFadeIn* fadeIn = CCFadeIn::create(1.0f);
        CCAction* pAction = CCCallFuncND::create(this, callfuncND_selector(QuestionLayer::noticeDelegate), NULL);
        spr->runAction(CCSequence::create(fadeIn, pAction, NULL));

        errorAnswer++;
        isAnswerFinished = true;

        //播放错误音效
        GameSoundManager::shareManager()->playAnswerError();
    }
}