Пример #1
0
//根据按钮跳转到相应的场景中
void MenuScene::menuCloseCallBack(CCObject* pSender)
{
    //点击音效
    SimpleAudioEngine::sharedEngine()->playEffect("ZF_Shoot_Effects_touchButton.wav");
    
    CCControlButton* button = (CCControlButton*)pSender;
    CCTransitionFade* transition;
    switch (button->getTag()) {
        case 1:
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
            transition = CCTransitionFade::create(0.2, Popularize::scene());
            CCDirector::sharedDirector()->pushScene(transition);
#endif
            break;
            
            
        case 2:
        {
            MallMarkets* mallMarketsLayer = MallMarkets::create();
            mallMarketsLayer->setPosition(CCPointZero);
            this->addChild(mallMarketsLayer,4);
            this->setMenuButtonTouchFasle();
            break;
        }

        case 4:

            break;

        case 6:

            break;
    }
    
}
Пример #2
0
void AddFriendScene::toolBarTouchDownAction(CCObject *pSender, CCControlEvent pCCControlEvent) {
	CCControlButton *button = (CCControlButton *)pSender;
	if (pCCControlEvent==CCControlEventTouchDown)
	{
		btnTouched = true;
	}
	else if (pCCControlEvent==CCControlEventTouchUpInside)
	{
		switch (button->getTag()) {
		case 128:
			{
				btnTouched = false;
				MainGameScene *mainScene = (MainGameScene *)this->getParent();
				mainScene->PushLayer((CCLayer *)this->GetLayer("NewMailScene"));
			}
			break;
		case 129:
			{
				btnTouched = false;
				CCMessageDialog *box = CCMessageDialog::create();
				box->setTitle(GlobalData::getLocalString("friend_add_confirm")->getCString());
				box->setDelegate(this);
				this->addChild(box);
			}
			break;
		default:
			break;
		}
	}
}
Пример #3
0
void QimiAlipayView::selected(cocos2d::CCNode* pSender, cocos2d::extension::CCControlEvent* pCCControlEvent)
{
    CCControlButton* btn = dynamic_cast<CCControlButton*>(pSender);
    int pay = btn->getTag();
    CCLog("%d", pay);
    upDataView(pay);
    upSelectState(btn);
}
Пример #4
0
void GamePan::refreshWorldPad()
{
	CCNode* pBaseNode = m_pCcbNode->getChildByTag(kTagGamePanWordPan);
	CCNode* tabNode = pBaseNode->getChildByTag(kTagGamePanWordPanTabBase);
	CCNode* itemNode = pBaseNode->getChildByTag(kTagGamePanWordPanItemBase);
	CCLabelTTF* itemTemp = dynamic_cast<CCLabelTTF*>(itemNode->getChildByTag(kTagGamePanWordPanItemTitle));
	CCControlButton* tabItem = dynamic_cast<CCControlButton*>(tabNode->getChildByTag(kTagGamePanWordPanTabBaseItem));
	float itemWidth = tabItem->getContentSize().width+ITEM_SPACE;
	float itemHeight = tabItem->getContentSize().height+ITEM_SPACE;
	for(int i =0;i<MAX_LINE;i++)
	{
		for(int j =0;j<MAX_ROW;j++)
		{
			CCControlButton* item = CCControlButton::create();
			Utils::copyCCControlButton(item,tabItem);
			item->setPosition(ccp(tabItem->getPositionX()+j*itemWidth,tabItem->getPositionY()-i*itemHeight));
			item->setTag(j+i*MAX_ROW);
			tabNode->addChild(item);

			CCLabelTTF* title = Utils::copyCCLabelTTF(itemTemp);
			title->setPosition(item->getPosition());
			title->setTag(j+i*MAX_ROW);
			itemNode->addChild(title);
			CCString* str = (CCString*)_wordList->randomObject();
			title->setString(str->getCString());
			_wordList->removeObject(str);
		}
	}

	for(int i =0;i<MAX_LINE;i++)
	{
		for(int j =0;j<MAX_ROW;j++)
		{
			CCControlButton* item = dynamic_cast<CCControlButton*>(tabNode->getChildByTag(j+i*MAX_ROW));
			XCheckBox* pCheckBox = XCheckBox::create(item);
			pCheckBox->setTag(item->getTag());
			pCheckBox->setToggle(false);
			pCheckBox->setTarget(this, cccontrol_selector(GamePan::wordSelectCallbackCCControl));
			tabNode->addChild(pCheckBox);
			item->removeFromParent();
		}
	}
	itemTemp->removeFromParent();
	tabItem->removeFromParent();
	refreshLetter();
}
Пример #5
0
void AddFriendScene::buttonClicked(CCObject *pSender,CCControlEvent event)
{
	CCLOG("i was clicked");
    
	MainGameScene *mainScene = (MainGameScene *)this->getParent();
	CCControlButton *button = (CCControlButton *)pSender;
	switch (button->getTag()) {
	case 101:
		CCLOG("11111");
		mainScene->PopLayer();
		break;
	case 102:
		mainScene->PopLayer();
		break;
	case 103:
		this->doSearchFriend();
		break;
	}
}
Пример #6
0
void ChatLayer::buttonClicked(CCObject *pSender, CCControlEvent pCCControlEvent) {
    
    CCControlButton *button = (CCControlButton*) pSender;
    
    switch (button->getTag()) {
        case 1:
        {
            CCLOG("chat");
            MainGameScene *mainScene = (MainGameScene *)this->getParent();
            mainScene->RemoveChatLayer();
            break;
        }
        case 2:
        {
            CCLOG("face");
            break;
        }
    }
}
Пример #7
0
//    按下按钮事件回调
void MailListScene::toolBarTouchDownAction(CCObject * sender , CCControlEvent controlEvent)
{
	CCControlButton *button = (CCControlButton *)sender;
	switch (button->getTag()) 
	{
	case 128:
		{
			MainGameScene *mainScene = (MainGameScene *)this->getParent();
			mainScene->PushLayer((CCLayer *)this->GetLayer("NewMailScene"));
			break;
		}
	case 130:
		{
			CCMessageDialog *box = CCMessageDialog::create();
			box->setTitle("Are you sure add this guy as your friends?");
			box->setDelegate(this);
			this->addChild(box);

			break;
		}
	}
}
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();
    }
}
Пример #9
0
void RPGMapItemsMenuLayer::onButton(cocos2d::CCObject *pSender, CCControlEvent event)
{
    SimpleAudioEngine::sharedEngine()->playEffect("audio_effect_btn.wav");
    
    CCControlButton *itemBtn = (CCControlButton*)pSender;
    
    if(itemBtn->getTag() == kRPGMapItemsMenuLayerTagBtnDiscard)
    {
//        CCLog("丢弃道具");
        
        RPGResultsLogic::discardItems(this->m_db, this->m_selectedItems->m_dataId);
        
        this->getParent()->removeChildByTag(kRPGMapSceneLayerTagChoicePlayerMenuLayerBg, true);
        this->getParent()->removeChildByTag(kRPGMapSceneLayerTagChoicePlayerMenuLayer, true);
        this->getParent()->removeChildByTag(kRPGMapItemsMenuLayerTagBtnDiscard, true);
        this->setVisible(true);
        
        this->loadItemsData();
    }
    else
    {
        for (int i = 0; i < this->m_itemsList->count(); i++)
        {
            //判断选中道具
            RPGExistingItems *itemsData = (RPGExistingItems*)this->m_itemsList->objectAtIndex(i);
            if(itemBtn->getTag() == itemsData->m_dataId)
            {
                this->m_selectedItems = itemsData;
                break;
            }
        }
        
        //因为动态获取地图的大小会导致了菜单层显示错位,所以定死了
        float width = 960;
        float height = 640;
        
        //临时背景
        CCTMXTiledMap *mainBg = CCTMXTiledMap::create(CCString::createWithFormat("map_menu3_%s.tmx", CCUserDefault::sharedUserDefault()->getStringForKey(GAME_STYLE).c_str())->getCString());
        mainBg->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width / 2, CCDirector::sharedDirector()->getWinSize().height / 2));
        mainBg->setAnchorPoint(ccp(0.5, 0.5));
        mainBg->setTag(kRPGMapSceneLayerTagChoicePlayerMenuLayerBg);
        this->getParent()->addChild(mainBg);
        
        CCString *title = CCString::createWithFormat(((CCString*)this->m_stringList->objectForKey("menu_items_choice"))->getCString(), this->m_selectedItems->m_name.c_str());
        RPGMapChoicePlayerMenuLayer *choicePlayer = RPGMapChoicePlayerMenuLayer::create(this->m_db, title, this, callfuncO_selector(RPGMapItemsMenuLayer::onChoicePlayer), width, height);
        choicePlayer->setTag(kRPGMapSceneLayerTagChoicePlayerMenuLayer);
        this->getParent()->addChild(choicePlayer);
        
        if(this->m_selectedItems->m_type != 3)
        {
//            CCLog("非道具不可以使用");
            choicePlayer->setHidden(true);
        }
        
        CCString *btnDiscardText = CCString::createWithFormat(((CCString*)this->m_stringList->objectForKey("menu_items_discard"))->getCString(), this->m_selectedItems->m_name.c_str());
        CCControlButton *btnDiscard = CCControlButton::create(btnDiscardText->getCString(), "Arial", 24);
        btnDiscard->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width / 2, 250));
        btnDiscard->setTag(kRPGMapItemsMenuLayerTagBtnDiscard);
        btnDiscard->addTargetWithActionForControlEvents(this, cccontrol_selector(RPGMapItemsMenuLayer::onButton), CCControlEventTouchUpInside);
        this->getParent()->addChild(btnDiscard);
        
        this->setVisible(false);
    }
    
}