void DropDownListSprite:: onSelected(CCObject * sender)
{
    CCMenuItem * item = dynamic_cast<CCMenuItem *>(sender);
    if (item)
    {
        m_lastSelectedIndex = item->getTag();
        m_showLabel->setString(m_selectLabels[item->getTag()]->getString());
    }
    
    onClose();
}
示例#2
0
void CardListScene::menuCallback(CCObject* pSender)
{
    CCMenuItem *menuItem = (CCMenuItem *)pSender;
    int tag=menuItem->getTag();
    if (menuItem->getTag()==TAG_MENU_BACK) {
        S_DR->replaceScene(CardShelfScene::scene());
    }else{
        S_AE->playEffect("E4.mp3");
        
        XieziCoverLayer* xieziCoverLayer=XieziCoverLayer::create(tag,NULL);
        xieziCoverLayer->setDelegate(this);
        this->addChild(xieziCoverLayer,INT_MAX);
    }
}
示例#3
0
void COxCJ4UILayer::OnTouchJetton(CCObject* pObject)
{
	CCMenuItem * pItem = dynamic_cast<CCMenuItem *>(pObject);
	if (pItem == NULL)
		return ;

	int nTag = pItem->getTag();
	if (nTag < m_nJetBeginTag || nTag >= (int)(m_nJetBeginTag + CountArray(m_pBtnJetton)))
	{
		CC_ASSERT(false);
		return ;
	}

	for (BYTE i = 0; i < CountArray(m_pBtnJetton); ++i)
	{
		if (m_pBtnJetton[i])
			m_pBtnJetton[i]->setVisible(false);
	}

	nTag -= m_nJetBeginTag;
	if (m_pJettonValue[nTag] == NULL)
		return ;

	if (m_pGameLayer->GetGameStatus() != GS_TK_SCORE)
		return ;

	LONGLONG lScore = 0;
	sscanf(m_pJettonValue[nTag]->getString(), "%lld", &lScore);

	m_pGameLayer->MePlaceJetton(lScore);
}
示例#4
0
void LayerMoney::onButtonClick(CCObject* pSender)
{
    CCMenuItem* mnu = (CCMenuItem*)pSender;
    int tag = mnu->getTag();
    if( currTag == tag )
        return;
    //
    switch (tag) {
        case tag_ChargeDisable:
            currTag = tag_ChargeEnable;
            gotoChargeMoney();
            break;
        case tag_HistoryDisable:
            currTag = tag_HistoryEnable;
            gotoHistory();
            break;
        case tag_TransferDisable:
            currTag = tag_TransferEnable;
            gotoTransfer("");
            break;
        case tag_LoanDisable:
            currTag = tag_LoanEnable;
            gotoBorrow();
            break;
        case tag_ExchangeDisable:
            currTag = tag_ExchangeEnable;
            gotoExchange();
            break;
    }
    disableTabs(currTag);
    CCLOG("onButtonClick with tag: %d", tag);}
void RPGMapItemsMenuLayer::onMenu(cocos2d::CCObject *pObject)
{
    CCMenuItem *menuItem = (CCMenuItem*)pObject;
    SimpleAudioEngine::sharedEngine()->playEffect("audio_effect_btn.wav");
    
    switch (menuItem->getTag())
    {
        case kRPGMapItemsMenuLayerTagMainMenuBack:
        {
//            CCLog("后退");
            
            //因为动态获取地图的大小会导致了菜单层显示错位,所以定死了
            float width = 960;
            float height = 640;
            RPGMapMenuLayer *menuLayer = menuLayer = RPGMapMenuLayer::create(this->m_stringList, this->m_db, width, height);
            menuLayer->setPosition(ccp((CCDirector::sharedDirector()->getWinSize().width - width) / 2.0, (CCDirector::sharedDirector()->getWinSize().height - height) / 2.0));
            menuLayer->setTag(kRPGMapSceneLayerTagMenuLayer);
            this->getParent()->addChild(menuLayer);
            
            this->removeFromParentAndCleanup(true);
            
        }
            break;
            
        default:
            break;
    }
    
}
void RPGStartSceneLayer::onDialog(cocos2d::CCObject *pObject)
{
    SimpleAudioEngine::sharedEngine()->playEffect("audio_effect_btn.wav");
    
    CCMenuItem *menuItem = (CCMenuItem*)pObject;
    
    switch (menuItem->getTag())
    {
        case kRPGStartSceneLayerTagDialogCancel:
        {
            this->removeChildByTag(kRPGStartSceneLayerTagDialog, true);
            
            CCMenu *mainMenu = (CCMenu*)this->getChildByTag(kRPGStartSceneLayerTagMainMenu);
            mainMenu->setEnabled(true);
        }
            break;
        default:
        {
            //kRPGStartSceneLayerTagMenuItemDialogOK
            
            //清除数据
            this->m_db.execDML("delete from save_data");
            this->m_db.execDML("delete from items_existing");
            this->m_db.execDML(GAME_INIT_SQL);
            
            //默认设置
            CCUserDefault::sharedUserDefault()->setStringForKey(GAME_STYLE, this->m_styleData[1].first);
            
            this->goToMapScene();
        }
            break;
    }
}
示例#7
0
void LayerFriend::onButtonClick(CCObject* pSender)
{
    CCMenuItem* mnu = (CCMenuItem*)pSender;
    int tag = mnu->getTag();
    if( currTag == tag )
        return;
    //
    switch (tag) {
        case tag_friendInfoDisable:
            currTag = tag_friendInfoEnable;
			gotoFriendDetails();
            //
            break;
        case tag_inviteDisable:
// 			CCNodeLoaderLibrary* ccNodeLoaderLibrary = SceneManager::getSingleton().getNodeLoaderLibrary();
// 			CCBReader* ccbReader = new cocos2d::extension::CCBReader(ccNodeLoaderLibrary);
// 			ccbReader = new cocos2d::extension::CCBReader(ccNodeLoaderLibrary);
// 			LayerInviteFriends* mLayer;
// 			if (ccbReader)
// 			{
// 				mLayer = (LayerInviteFriends *)ccbReader->readNodeGraphFromFile( "LayerInviteFriends.ccbi" );
// 				this->addChild(mLayer, 1, 1);
// 				ccbReader->release();
// 			}
// 			
			gotoInviteFriends();
            //return;
            currTag = tag_inviteEnable;
            break;
    }
    disableTabs(currTag);
    CCLOG("onButtonClick with tag: %d", tag);}
示例#8
0
文件: Senario.cpp 项目: keyor/Nanhua
void Senario::selectButtonPressed(CCObject* pSender)
{
    CCMenuItem* pMenuItem = (CCMenuItem *)(pSender);
    int index = pMenuItem->getTag();
    
    Slide* slide = (Slide*)slidesList->objectAtIndex(curSlide);
    CCArray* elementArray = slide->elementList;
    Element* ele = (Element*)elementArray->objectAtIndex(index);
    
    if(ele->outcome)
    {
        GameScene::getThis()->globalOutcomeModifier->banditsModifier = ele->banditsModifier;
        GameScene::getThis()->globalOutcomeModifier->refugeesModifier = ele->refugeeModifier;
        GameScene::getThis()->globalOutcomeModifier->goldModifier = ele->goldModifier;
        GameScene::getThis()->globalOutcomeModifier->foodModifier = ele->foodModifier;
        GameScene::getThis()->globalOutcomeModifier->populationModifier = ele->populationModifier;
    }
    
    string fileName = ele->nextFile;
    slidesList->removeAllObjects();
    CC_SAFE_RELEASE(slidesList);
    
    SenarioManager* sm = new SenarioManager();
    sm->parseXMLFile(fileName.c_str());
    
    slidesList = sm->slidesList;
    delete sm;
    
    inOption = false;

    curSlide = 0;
    if(!constructSenarioStage(false)){
        buttonSelect();
    }
}
示例#9
0
void MovieMenu::menuCallback_Selet(CCObject* pSender)
{
	setKeypadEnabled(false);

	CCDirector::sharedDirector()->purgeCachedData();

	CCMenuItem *item = (CCMenuItem*)pSender;

	bool bCallCamera = false;
	if ( PROJECT_TYPE == TYPE_BABYPRESIDENT )
	{
		CCLog ("MovieMenu menuCallback_Selet - item->getTag() : %d", item->getTag());
		bool bUserImgIndex = false;

		switch(item->getTag())
		{
		case USER_IMG_1ST:
			bUserImgIndex = CCUserDefault::sharedUserDefault()->getBoolForKey("have_userImg", false);
			if ( false == bUserImgIndex )
				bCallCamera = true;
			break;
		case USER_IMG_2ND:
			bUserImgIndex = CCUserDefault::sharedUserDefault()->getBoolForKey("have_userImg2", false);
			if ( false == bUserImgIndex )
				bCallCamera = true;
			break;
		case USER_IMG_3TH:
			bUserImgIndex = CCUserDefault::sharedUserDefault()->getBoolForKey("have_userImg3", false);
			if ( false == bUserImgIndex )
				bCallCamera = true;
			break;
		}
	}
	else
	{
		SELECT_GAME game;
		game.nLevel = m_nGameLevel;
		game.nImgIndex = item->getTag();

		CCScene *pScene = JS_Main::scene(game);
	//	CCDirector::sharedDirector()->pushScene(CCTransitionFade::create( 0.3f, pScene ) );
		CCDirector::sharedDirector()->replaceScene(CCTransitionFade::create( 0.3f, pScene ) );
	}
}
示例#10
0
void CChooseLetterWindow::LetterBtnClick(Object* sender)
{	
	if(!m_ChoosenLetter)
	{
		return;
	}
	CCMenuItem * button = (CCMenuItem*) sender;
	m_ChoosenLetter->SetLetter((char)button->getTag());
	Hide();
}
示例#11
0
void BoxMenu::newGame(CCObject* pSender)
{
	Score *scoreInstance = Score::GetInstance();

	CCMenuItem *menuItem = (CCMenuItem *)pSender;
	scoreInstance->teamTag = menuItem->getTag();

	std::cout << "get tag:" << scoreInstance->teamTag << std::endl;

    CCDirector::sharedDirector()->replaceScene(GameScene::sceneWithStage(0));
}
void GymnasticGameScene::gymnasticControlCallBack(CCObject* pSender) {
	CCMenuItem *item = (CCMenuItem*) pSender;
		int tag = item->getTag();
		if(tag==1)
		{
			_player->setRotation(_player->getRotation()+5);
		}else
		{
			_player->setRotation(_player->getRotation()-5);
		}
}
示例#13
0
void Tower::upgrade(CCObject *sender) {
    if (sender) {
        CCMenuItem *item = (CCMenuItem *)sender;
        
        TowerType type = (TowerType)item->getTag();
        setArchitecture(Architecture::getArchitectureForType(type));
        
        GameModel::instance()->getPopupMenu()->closeMenu();
        GameModel::instance()->getGamePlayScene()->removeChildByTag(kTowerDescriptionTag, true);
    }
}
void MainScene::MenuCallback(CCObject* sender)
{
   // This is a very contrived example
   // for handling the menu items.
   // -1 ==> Left Arrow
   // -2 ==> Right Arrow
   // Anything else is a selection
   CCMenuItem* pMenuItem = (CCMenuItem*)sender;
   switch(pMenuItem->getTag())
   {
      case ARROW_LEFT:
         PageLeft();
         break;
      case ARROW_RIGHT:
         PageRight();
         break;
      default:
         CCLOG("Got Item %d Pressed",pMenuItem->getTag());
         break;
   }
}
void TestController::menuCallback(cocos2d::CCObject *pSender)
{
    CCMenuItem* pMenuItem = (CCMenuItem *)(pSender);
    int nIdx = pMenuItem->getTag() - 10000;
    CCLOG("click menu index = %d", nIdx);
    // create the test scene and run it
    TestBaseLayer* layer = CreateTestScene(nIdx);
    if (layer)
    {
        layer->runThisLayer();
    }
    
}
void RPGMapItemsMenuLayer::onChoicePlayer(cocos2d::CCObject *pObject)
{
    SimpleAudioEngine::sharedEngine()->playEffect("audio_effect_btn.wav");
    
    CCMenuItem *menuItem = (CCMenuItem*)pObject;
    if(menuItem->getTag() == kRPGMapChoicePlayerMenuLayerTagMainMenuBack)
    {
        //按了退出
        this->getParent()->removeChildByTag(kRPGMapSceneLayerTagChoicePlayerMenuLayerBg, true);
        this->getParent()->removeChildByTag(kRPGMapSceneLayerTagChoicePlayerMenuLayer, true);
        this->getParent()->removeChildByTag(kRPGMapItemsMenuLayerTagBtnDiscard, true);
        this->setVisible(true);
    }
    else
    {
        bool isSuccess = RPGResultsLogic::useItems(this->m_db, menuItem->getTag() - kRPGMapChoicePlayerMenuLayerTagMainMenuPlayer, this->m_selectedItems->m_dataId);
        if(!isSuccess)
        {
            //道具使用失败
            CCSize winSize = CCDirector::sharedDirector()->getWinSize();
            RPGDialogLayer *dialog = RPGDialogLayer::create(((CCString*)this->m_stringList->objectForKey("menu_items_fail"))->getCString(), ((CCString*)this->m_stringList->objectForKey("confirm_exit_ok"))->getCString(), kRPGMapItemsMenuLayerTagDialogOK, winSize.width, winSize.height, this, menu_selector(RPGMapItemsMenuLayer::onDialog));
            dialog->setTag(kRPGMapItemsMenuLayerTagDialog);
            this->getParent()->addChild(dialog);
            
        }
        else
        {
            //道具使用成功
            this->getParent()->removeChildByTag(kRPGMapSceneLayerTagChoicePlayerMenuLayerBg, true);
            this->getParent()->removeChildByTag(kRPGMapSceneLayerTagChoicePlayerMenuLayer, true);
            this->getParent()->removeChildByTag(kRPGMapItemsMenuLayerTagBtnDiscard, true);
            this->setVisible(true);
            
            this->loadItemsData();
        }
    }
    
}
示例#17
0
void RS_Main::menuClickCallback(CCObject* pSender)
{
    CCMenuItem *item = (CCMenuItem*)pSender;

    switch(item->getTag()) {
    case 1:	// 뒤로가기
    {
        m_pBottomBar->setOpacity(255);

        bool bCallFromMissionSelect = CCUserDefault::sharedUserDefault()->getBoolForKey("CallFromMissionSelectScene", false);

        if ( false == bCallFromMissionSelect )
        {
            LanguageUtil::setSoundForMission(false);

            CCScene * pScene = (CCScene *)CCScene::create();

            CEbookLayer *layer = new CEbookLayer(m_nCurEBookPage);

            if (pScene && layer) {
                layer->autorelease();
                pScene->addChild(layer);

                CCScene *pTemp = CCTransitionPullToT::create(1.0f,pScene);
                CCDirector::sharedDirector()->replaceScene(pTemp);
            }
        }
        else
        {
            CCUserDefault::sharedUserDefault()->setBoolForKey("CallFromMissionSelectScene", false);
            CCUserDefault::sharedUserDefault()->flush();

            CCScene *pScene = Mission_Select::scene();
            CCDirector::sharedDirector()->pushScene( CCTransitionPullToT::create( 1.0f, pScene ) );
        }
    }
    break;
    case 2: // 다시하기
        blendImage();
        break;

    case 4:	// 수학/과학 미션 안내 팝업 터치
    {
        m_pInfoItem->setVisible(false);
    }
    break;
    }
}
示例#18
0
void RS_Main::scrollMenuCallback(CCObject* pSender)
{
    if (EASY == m_nGameLevel)
        return;

    CCMenuItem *item = (CCMenuItem*)pSender;

    switch (item->getTag()) {
    case RIGHT:
    {
        CCLog("RS_Main::scrollMenuCallback - RIGHT");
        //float fW = m_scrollVQ->getContentSize().width - SCROLL_ITEM_GAP_Q;
        //m_scrollVQ->setContentOffsetInDuration(ccp(-fW/2, 0), 1.0f);

        float width = m_scrollVQ->getContentSize().width;

        // 우측 끝 판단기준용 offset.x 값
        float fRightOffset = width - s.width;

        CCPoint pt = m_scrollVQ->getContentOffset();
        float fDur = 2.0f * (fRightOffset - (- pt.x) ) / fRightOffset;

        m_scrollVQ->setContentOffsetInDuration(ccp(-fRightOffset, 0), fDur);

    }
    break;
    case LEFT:
    {
        CCLog("RS_Main::scrollMenuCallback - LEFT");

        float width = m_scrollVQ->getContentSize().width;

        // 우측 끝 판단기준용 offset.x 값
        float fRightOffset = width - s.width;

        CCPoint pt = m_scrollVQ->getContentOffset();
        float fDur = 2.0f * (- pt.x) / fRightOffset;

        m_scrollVQ->setContentOffsetInDuration(ccp(0, 0), fDur);
    }
    break;
    }
}
示例#19
0
void PlayScene::gamemenuCallBack(CCObject* pSender) {
	AudioManager::getAudioManager()->playEffectAudio(SOUND_CLICK);
	CCMenuItem *item = (CCMenuItem*) pSender;
	int tag = item->getTag();
	if(tag==1)
	{
		CCScene* rScene = MenuScene::scene();
			CCDirector::sharedDirector()->pushScene(rScene);
	}
	else if(tag==2)
	{
		restart();
	}
	else
	{
		CCScene* rScene = StoreScene::scene();
		CCDirector::sharedDirector()->replaceScene(rScene);
	}
}
示例#20
0
void FC_Intro::menuClickCallback(CCObject* pSender)
{
	CCMenuItem *item = (CCMenuItem*)pSender;
	int nTag = item->getTag();

	switch(nTag) {
		case 1: // 쉬움
			m_pMenuItem1->selected();
			m_pMenuItem2->unselected();

			m_nGameLevel = LV_EASY;
			CCUserDefault::sharedUserDefault()->setIntegerForKey("FC_GAME_LEVEL", m_nGameLevel);
			CCUserDefault::sharedUserDefault()->flush();
			break;
		case 2: // 어려움
			m_pMenuItem2->selected();
			m_pMenuItem1->unselected();

			m_nGameLevel = LV_HARD;
			CCUserDefault::sharedUserDefault()->setIntegerForKey("FC_GAME_LEVEL", m_nGameLevel);
			CCUserDefault::sharedUserDefault()->flush();
			break;
		case 3: // 뒤로가기
			{	
			CCDirector::sharedDirector()->purgeCachedData();

			InfoScene *pScene = new InfoScene();
			if (pScene)
			{
				pScene->runThisScene();
				pScene->release();
			}
			break;
			}
		case 4: // 시작
			setKeypadEnabled(false);
			CCScene *pScene = FC_Main::scene(m_nGameLevel);
			CCDirector::sharedDirector()->pushScene( CCTransitionFade::create( 0.3f, pScene ) );
			break;
	}
}
示例#21
0
void SP_Main::menuClickCallback(CCObject* pSender)
{
	CCMenuItem *item = (CCMenuItem*)pSender;

	switch(item->getTag()) {
		case 1:	// 뒤로가기
			CCDirector::sharedDirector()->purgeCachedData();
			{
				InfoScene *pScene = new InfoScene();
				if (pScene)
				{
					pScene->runThisScene();
					pScene->release();
				}
			}
			break;
		case 2: // 다시하기
			shuffle(); // 섞기
			break;
	}
}
示例#22
0
void TanSuoLayer::menuItemClicked_JieFenHeroSelect(CCObject *pSender)
{
	CCMenuItem *item = (CCMenuItem*)pSender;
	int tag = item->getTag();

	for (vector<CCMenuItem*>::iterator iter = m_lMenuItemList.begin() ; iter != m_lMenuItemList.end() ; iter ++)
	{
		if ((*iter)->getTag() == tag)
		{
			(*iter)->setEnabled(false);
		}
		else
		{
			(*iter)->setEnabled(true);
		}
	}
	if (m_nSelectProId == -1)
	{
		CCMenu *menu = (CCMenu*)(item->getParent());
		CCMenuItemImage* menuItemOk = CCMenuItemImage::create(
			"shangpin_goumai_queren.png",
			"shangpin_goumai_queren_select.png",
			this,SEL_MenuHandler(&TanSuoLayer::selectJieFengHero));

		CCNode *node = menu->getParent()->getParent()->getParent()->getParent();
		CCNode *diaoLogMenu = node->getChildByTag(0);
		menuItemOk->setPosition(ccp(node->getContentSize().width/2,0));
		diaoLogMenu->addChild(menuItemOk);
	}
	
	m_nSelectProId = tag;
	/*
	CCDirector::sharedDirector()->getRunningScene()->removeChildByTag(TAG_AwardDisplayer_Layer);

	Profession profId = (Profession)tag;

	addObserver(callfuncO_selector(TanSuoLayer::rsp_jiefen), MSG_unlockDiscoverSealRsp_F);
	mCmdHlp->cmdUnlockDiscoverSeal(profId);*/
}
void MainMenuScene::menuTouchCallBack(cocos2d::CCObject *pSender)
{
    CCMenuItem* pMenuItem = (CCMenuItem *)pSender;
    
    Director *director = Director::getInstance();
    
    switch (pMenuItem->getTag()) {
        case 1: {
            CocosDenshion::SimpleAudioEngine::sharedEngine()->stopBackgroundMusic();
            CocosDenshion::SimpleAudioEngine::sharedEngine()->playBackgroundMusic("sound/MainBGM.mp3", true);
            
			MapScene* gameScene = MapScene::create();
            director->replaceScene(TransitionFade::create(1.0f, gameScene));
            break;
        }
        case 2:{
            Scene* creditScene = CreditScene::createScene();
            director->replaceScene(TransitionFade::create(1.0f,creditScene));
            break;
        }
    }
}
示例#24
0
void SP_Main::menuShow(CCObject* pSender)
{
	CCMenuItem *item = (CCMenuItem*)pSender;
	int nTag = item->getTag();

	if (0 == nTag) {

		if (m_bShwoN) {
			showLabel(false, 0);
			m_pShowNItem->unselected();
			m_bShwoN = false;
		}
		else {
			showLabel(true, 0);
			showLabel(false, 1);
			m_pShowNItem->selected();
			m_pShowAItem->unselected();
			m_bShwoN = true;
			m_bShwoA = false;
		}
	}
	else {
		if (m_bShwoA) {
			showLabel(false, 1);
			m_pShowAItem->unselected();
			m_bShwoA = false;
		}
		else {
			showLabel(true, 1);
			showLabel(false, 0);
			m_pShowAItem->selected();
			m_pShowNItem->unselected();
			m_bShwoA = true;
			m_bShwoN = false;
		}
	}
}
示例#25
0
void JS_Result::menuClickCallback(CCObject* pSender)
{
	CCMenuItem *item = (CCMenuItem*)pSender;

	CCScene *pScene = NULL;
	switch(item->getTag()) {
		case 1:	// OK
			CCDirector::sharedDirector()->purgeCachedData();
			pScene = JS_Select::scene();
			CCDirector::sharedDirector()->replaceScene(CCTransitionFade::create( 0.3f, pScene ));
			break;
/*
		case 2: // 다시하기
			setKeypadEnabled(false);
			CCDirector::sharedDirector()->purgeCachedData();
			SELECT_GAME sg;
			sg.nLevel = m_nGameLevel;
			sg.nImgIndex = m_nBGIndex;
			pScene = JS_Main::scene(sg);
			CCDirector::sharedDirector()->replaceScene( CCTransitionFade::create( 0.3f, pScene ) );
			break;
*/
	}
}
示例#26
0
void MovieMenu::menuClickCallback(CCObject* pSender)
{
	CCMenuItem *item = (CCMenuItem*)pSender;

	switch(item->getTag()) {
		case EASY_BTN_TAG:
			{
			m_pMenuItem1->selected();
			m_pMenuItem2->unselected();
			m_nGameLevel = LV_EASY;
			CCUserDefault::sharedUserDefault()->setIntegerForKey("JS_GAME_LEVEL", m_nGameLevel);
			CCUserDefault::sharedUserDefault()->flush();

			CCDirector::sharedDirector()->purgeCachedData();
			CCScene *pScene = NULL;

			pScene = MovieMenu::scene();
			CCDirector::sharedDirector()->replaceScene(CCTransitionFade::create( 0.3f, pScene ));
			}
			break;
		case HARD_BTN_TAG:
			{
			m_pMenuItem2->selected();
			m_pMenuItem1->unselected();
			m_nGameLevel = LV_HARD;
			CCUserDefault::sharedUserDefault()->setIntegerForKey("JS_GAME_LEVEL", m_nGameLevel);
			CCUserDefault::sharedUserDefault()->flush();

			CCDirector::sharedDirector()->purgeCachedData();
			CCScene *pScene = NULL;

			pScene = MovieMenu::scene();
			CCDirector::sharedDirector()->replaceScene(CCTransitionFade::create( 0.3f, pScene ));
			}
			break;
		case BACK_BTN_TAG:
		//	CCDirector::sharedDirector()->popSceneWithTransition<CCTransitionPullToR>(0.5f);
			CCDirector::sharedDirector()->purgeCachedData();
			{
				InfoScene *pScene = new InfoScene();
				if (pScene)
				{
					pScene->runThisScene();
					pScene->release();
				}
			}
			break;
		case AGAIN_BTN_TAG:
			// AGAIN_BTN_TAG
			{
				char cGamePlayedFlag[20];
				for (int i = 0; i < 10; i++)
				{
					if ( LV_EASY == m_nGameLevel )
						sprintf(cGamePlayedFlag, "js_played_easy_%d", i+1);
					else
						sprintf(cGamePlayedFlag, "js_played_hard_%d", i+1);

					CCUserDefault::sharedUserDefault()->setBoolForKey(cGamePlayedFlag, false);
				}
				CCUserDefault::sharedUserDefault()->setIntegerForKey("JS_GAME_LEVEL", m_nGameLevel);
				CCUserDefault::sharedUserDefault()->flush();

				CCDirector::sharedDirector()->purgeCachedData();
				CCScene *pScene = NULL;

				pScene = MovieMenu::scene();
				CCDirector::sharedDirector()->replaceScene(CCTransitionFade::create( 0.3f, pScene ));
			}
			break;

		case USERIMG_BTN_TAG:
			{
			CCLog ("MovieMenu USERIMG_BTN_TAG");

			//CCSpriteFrameCache::purgeSharedSpriteFrameCache();
			//CCTextureCache::purgeSharedTextureCache();
			CCDirector::sharedDirector()->purgeCachedData();

			SELECT_GAME game;
			game.nLevel = m_nGameLevel;
			game.nImgIndex = 13;

			CCScene *pScene = CCScene::create();
			pScene = JS_Main::scene(game);
			//CCDirector::sharedDirector()->replaceScene(CCTransitionFade::create( 0.3f, pScene ) );
			CCDirector::sharedDirector()->pushScene(CCTransitionFade::create( 0.3f, pScene ) );
			}
			break;

		
	}
}
示例#27
0
void RPGBattleMenu::onMenu(cocos2d::CCObject *pObject)
{
    CCMenuItem *menuItem = (CCMenuItem*)pObject;
    SimpleAudioEngine::sharedEngine()->playEffect("audio_effect_btn.wav");

    switch (menuItem->getTag())
    {
        case kRPGBattleMenuTagSkill:
        {
            CCLog("技能");
            
            this->hideMenu();
            
            this->m_selectedMenuTag = kRPGBattleMenuTagSkill;
            
            CCMenuItemSprite *menuCancel = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("commons_btn_back_04.png"), CCSprite::createWithSpriteFrameName("commons_btn_back_04.png"), this, menu_selector(RPGBattleMenu::onMenu));
            menuCancel->setPosition(ccp(43, 596));
            menuCancel->setTag(kRPGBattleMenuTagCancel);
            menuCancel->setScale(0.75);
            this->addChild(menuCancel);
            
            CCTMXTiledMap *selectLayer = CCTMXTiledMap::create(CCString::createWithFormat("battle_select_%s.tmx", CCUserDefault::sharedUserDefault()->getStringForKey(GAME_STYLE).c_str())->getCString());
            selectLayer->setPosition(ccp((CCDirector::sharedDirector()->getWinSize().width - selectLayer->getContentSize().width) / 2, (CCDirector::sharedDirector()->getWinSize().height - selectLayer->getContentSize().height) / 2));
            selectLayer->setTag(kRPGBattleSceneLayerTagSkillSelectDialog);
            
            ((RPGBattleSceneLayer*)this->m_parentNode)->addChild(selectLayer);            
            ((RPGBattleSceneLayer*)this->m_parentNode)->enabledTouched(true);
            
            //显示title和分隔线
            addLab(selectLayer, 199, (CCString*)this->m_stringList->objectForKey("skill_title"), 25, ccp(310, 285));
            CCLabelTTF *titleLab = (CCLabelTTF*)selectLayer->getChildByTag(199);
            titleLab->setFontFillColor(ccc3(144, 144, 144));
            
            CCSprite *separate = CCSprite::createWithSpriteFrameName("separate.png");
            separate->setPosition(ccp(selectLayer->getContentSize().width / 2, 260));
            separate->setScaleX(0.65);
            separate->setTag(198);
            selectLayer->addChild(separate);
            
            //加载技能数据
            CCTableView *tableView = (CCTableView*)selectLayer->getChildByTag(197);
            if(!tableView)
            {
                tableView = CCTableView::create(this, ccp(selectLayer->getContentSize().width, selectLayer->getContentSize().height - 80));
                tableView->setDirection(kCCScrollViewDirectionVertical);
                tableView->setPosition(CCSizeZero);
                tableView->setDelegate(this);
                tableView->setVerticalFillOrder(kCCTableViewFillTopDown);
                tableView->setTag(197);
                selectLayer->addChild(tableView);
                
            }
            
            this->m_tableItems->removeAllObjects();

            string wq = "";
            JsonBox::Value json;
            json.loadFromString(this->m_playerData->m_skill.c_str());
            JsonBox::Array jsonArr = json.getArray();
            for (int i = 0; i < jsonArr.size(); i++)
            {
                char* str = (char*)malloc(10 * sizeof(char));
                OzgCCUtility::itoa(jsonArr[i].getInt(), str);
                wq.append(str);
                
                if(i + 1 < jsonArr.size())
                    wq.append(", ");
                
                free(str);
            }
            if((int)wq.length() > 0)
            {
                CppSQLite3Query query = this->m_db->execQuery(CCString::createWithFormat(SKILL_QUERY, wq.c_str())->getCString());
                while(!query.eof())
                {
                    RPGSkillBtnData *skill = RPGSkillBtnData::create();
                    skill->m_dataId = query.getIntField("id");
                    skill->m_name = query.getStringField("name_cns");
                    skill->m_MP = query.getIntField("mp");
                    skill->m_skillAttack = query.getIntField("skill_attack");
                    skill->m_type = query.getIntField("type");
                    skill->m_attr = query.getIntField("attr");
                    skill->m_enabled = true;
                    
                    //不能使用技能的情况
                    if(this->m_playerData->m_MP <= 0 || this->m_playerData->m_HP <= 0)
                        skill->m_enabled = false;
                    else if(this->m_playerData->m_MP < skill->m_MP)
                        skill->m_enabled = false;
                    
                    this->m_tableItems->addObject(skill);
                    
                    query.nextRow();
                }
                query.finalize();
            }
            
            tableView->reloadData();
            //加载技能数据 end
            
            ((RPGBattleSceneLayer*)this->m_parentNode)->enabledTouched(false);
        }
            break;
        case kRPGBattleMenuTagItems:
        {
            CCLog("道具");
            
            this->hideMenu();
            
            this->m_selectedMenuTag = kRPGBattleMenuTagItems;
            
            CCMenuItemSprite *menuCancel = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("commons_btn_back_04.png"), CCSprite::createWithSpriteFrameName("commons_btn_back_04.png"), this, menu_selector(RPGBattleMenu::onMenu));
            menuCancel->setPosition(ccp(43, 596));
            menuCancel->setTag(kRPGBattleMenuTagCancel);
            menuCancel->setScale(0.75);
            this->addChild(menuCancel);
            
            CCTMXTiledMap *selectLayer = CCTMXTiledMap::create(CCString::createWithFormat("battle_select_%s.tmx", CCUserDefault::sharedUserDefault()->getStringForKey(GAME_STYLE).c_str())->getCString());
            selectLayer->setPosition(ccp((CCDirector::sharedDirector()->getWinSize().width - selectLayer->getContentSize().width) / 2, (CCDirector::sharedDirector()->getWinSize().height - selectLayer->getContentSize().height) / 2));
            selectLayer->setTag(kRPGBattleSceneLayerTagItemsSelectDialog);
            
            ((RPGBattleSceneLayer*)this->m_parentNode)->addChild(selectLayer);
            ((RPGBattleSceneLayer*)this->m_parentNode)->enabledTouched(true);
            
            //显示title和分隔线
            addLab(selectLayer, 199, (CCString*)this->m_stringList->objectForKey("items_title"), 25, ccp(310, 285));
            CCLabelTTF *titleLab = (CCLabelTTF*)selectLayer->getChildByTag(199);
            titleLab->setFontFillColor(ccc3(144, 144, 144));
            
            CCSprite *separate = CCSprite::createWithSpriteFrameName("separate.png");
            separate->setPosition(ccp(selectLayer->getContentSize().width / 2, 260));
            separate->setScaleX(0.65);
            separate->setTag(198);
            selectLayer->addChild(separate);
            
            //加载道具数据
            CCTableView *tableView = (CCTableView*)selectLayer->getChildByTag(197);
            if(!tableView)
            {
                tableView = CCTableView::create(this, ccp(selectLayer->getContentSize().width, selectLayer->getContentSize().height - 80));
                tableView->setDirection(kCCScrollViewDirectionVertical);
                tableView->setPosition(CCSizeZero);
                tableView->setDelegate(this);
                tableView->setVerticalFillOrder(kCCTableViewFillTopDown);
                tableView->setTag(197);
                selectLayer->addChild(tableView);
            }
            
            this->m_tableItems->removeAllObjects();
            
            CCArray *existingItems = ((RPGBattleSceneLayer*)this->m_parentNode)->m_existingItems;
            
            for (int i = 0; i < existingItems->count(); i++)
                this->m_tableItems->addObject(existingItems->objectAtIndex(i));
            
            tableView->reloadData();
            //加载道具数据 end
            
            ((RPGBattleSceneLayer*)this->m_parentNode)->enabledTouched(false);
        }
            break;
        case kRPGBattleMenuTagEscape:
        {
//            CCLog("逃跑");
            
            float success = CCRANDOM_0_1();
            if(success >= 0.0 && success <= 0.5)
            {
//                CCLog("逃跑成功");
                
                this->setEnabled(false);
                this->removeFromParentAndCleanup(true);
                
                ((RPGBattleSceneLayer*)this->m_parentNode)->goToMap();
            }
            else
            {
                ((RPGBattleSceneLayer*)this->m_parentNode)->showMsg((CCString*)this->m_stringList->objectForKey("escape_fail"));
                
                //重置进度条
                this->m_playerData->m_progress = 0.0;
                CCProgressTimer *battleProgress = (CCProgressTimer*)this->m_parentNode->getChildByTag(kRPGBattleSceneLayerTagPlayerProgress + this->m_playerData->m_dataId);
                battleProgress->setPercentage(this->m_playerData->m_progress);
                
                ((RPGBattleSceneLayer*)this->m_parentNode)->scheduleUpdate();
                
                CCTMXTiledMap *bgLayer = (CCTMXTiledMap*)this->m_parentNode->getChildByTag(kRPGBattleMenuTagBg);
                bgLayer->removeFromParentAndCleanup(true);
                this->removeFromParentAndCleanup(true);
            }
            
        }
            break;
        case kRPGBattleMenuTagCancel:
        {
//            CCLog("取消");
            this->showMenu();
            
            CCMenuItem *menuCancel = (CCMenuItem*)this->getChildByTag(kRPGBattleMenuTagCancel);
            menuCancel->removeFromParentAndCleanup(true);
            
            switch (this->m_selectedMenuTag)
            {
                case kRPGBattleMenuTagAttack:
                    CCLog("取消攻击");
                    ((RPGBattleSceneLayer*)this->m_parentNode)->enabledTouched(false);
                    ((RPGBattleSceneLayer*)this->m_parentNode)->cancelAllSelected();
                    
                    break;
                case kRPGBattleMenuTagSkill:
                    CCLog("取消技能列表");
                    
                    if(((RPGBattleSceneLayer*)this->m_parentNode)->getChildByTag(kRPGBattleSceneLayerTagSkillSelectDialog))
                        ((RPGBattleSceneLayer*)this->m_parentNode)->removeChildByTag(kRPGBattleSceneLayerTagSkillSelectDialog, true);
                    
                    ((RPGBattleSceneLayer*)this->m_parentNode)->enabledTouched(false);
                    ((RPGBattleSceneLayer*)this->m_parentNode)->cancelAllSelected();
                    
                    break;
                case kRPGBattleMenuTagItems:
                    CCLog("取消道具列表");
                    
                    if(((RPGBattleSceneLayer*)this->m_parentNode)->getChildByTag(kRPGBattleSceneLayerTagItemsSelectDialog))
                        ((RPGBattleSceneLayer*)this->m_parentNode)->removeChildByTag(kRPGBattleSceneLayerTagItemsSelectDialog, true);
                    
                    ((RPGBattleSceneLayer*)this->m_parentNode)->enabledTouched(false);
                    ((RPGBattleSceneLayer*)this->m_parentNode)->cancelAllSelected();
                    
                    break;
//                default:
//                    break;
            }
            
        }
            break;
        case kRPGBattleMenuTagCancel2:
        {
            //这个选择了一个技能或道具后,到了选择目标对象的一步,使用到的取消按钮
            
            CCMenuItemSprite *menuCancel = (CCMenuItemSprite*)this->getChildByTag(kRPGBattleMenuTagCancel);
            menuCancel->setVisible(true);
            
            CCMenuItemSprite *menuCancel2 = (CCMenuItemSprite*)this->getChildByTag(kRPGBattleMenuTagCancel2);
            menuCancel2->removeFromParentAndCleanup(true);
            
            if(this->m_parentNode->getChildByTag(kRPGBattleSceneLayerTagItemsSelectDialog))
                this->m_parentNode->getChildByTag(kRPGBattleSceneLayerTagItemsSelectDialog)->setVisible(true);
            
            if(this->m_parentNode->getChildByTag(kRPGBattleSceneLayerTagSkillSelectDialog))
                this->m_parentNode->getChildByTag(kRPGBattleSceneLayerTagSkillSelectDialog)->setVisible(true);
            
            ((RPGBattleSceneLayer*)this->m_parentNode)->enabledTouched(false);
            ((RPGBattleSceneLayer*)this->m_parentNode)->cancelAllSelected();
        }
            break;
        default:
        {
            CCLog("攻击");
            this->hideMenu();
            
            this->m_selectedMenuTag = kRPGBattleMenuTagAttack;
            
            CCMenuItemSprite *menuCancel = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("commons_btn_back_04.png"), CCSprite::createWithSpriteFrameName("commons_btn_back_04.png"), this, menu_selector(RPGBattleMenu::onMenu));
            menuCancel->setPosition(ccp(43, 596));
            menuCancel->setTag(kRPGBattleMenuTagCancel);
            menuCancel->setScale(0.75);
            this->addChild(menuCancel);
            
            ((RPGBattleSceneLayer*)this->m_parentNode)->enabledTouched(true);
            
        }
            break;
    }
    
}
void RPGStartSceneLayer::onMenu(cocos2d::CCObject *pObject)
{
    CCMenuItem *menuItem = (CCMenuItem*)pObject;
    
    switch (menuItem->getTag())
    {
        case kRPGStartSceneLayerTagMainMenuItemRestart:
        {
            //重新开始
            SimpleAudioEngine::sharedEngine()->playEffect("audio_effect_btn.wav");
            
            CCSize winSize = CCDirector::sharedDirector()->getWinSize();
            
            RPGDialogLayer *dialog = RPGDialogLayer::create(((CCString*)this->m_stringList->objectForKey("confirm_delete"))->getCString(), ((CCString*)this->m_stringList->objectForKey("confirm_ok"))->getCString(), kRPGStartSceneLayerTagDialogOK, ((CCString*)this->m_stringList->objectForKey("confirm_cancel"))->getCString(), kRPGStartSceneLayerTagDialogCancel, winSize.width, winSize.height, this, menu_selector(RPGStartSceneLayer::onDialog));
            dialog->setTag(kRPGStartSceneLayerTagDialog);
            this->addChild(dialog);
            
            CCMenu *mainMenu = (CCMenu*)this->getChildByTag(kRPGStartSceneLayerTagMainMenu);
            mainMenu->setEnabled(false);
        }
            break;
        case kRPGStartSceneLayerTagMainMenuItemSettings:
        {
            //游戏设置
            SimpleAudioEngine::sharedEngine()->playEffect("audio_effect_btn.wav");
            
            this->removeChildByTag(kRPGStartSceneLayerTagMainMenu, true);
            this->showSettingsMenu();
            
        }
            break;
        case kRPGStartSceneLayerTagSettingsBack:
        {
            //游戏设置里面的返回
            SimpleAudioEngine::sharedEngine()->playEffect("audio_effect_btn.wav");
            
            this->removeChildByTag(kRPGStartSceneLayerTagSettingsMenu, true);
            this->removeChildByTag(kRPGStartSceneLayerTagLabStyle, true);
            this->removeChildByTag(kRPGStartSceneLayerTagLabCurrStyle, true);
            this->showMainMenu();
            
        }
            break;
        case kRPGStartSceneLayerTagSettingsRestore:
        {
            //点击了还原设置
            SimpleAudioEngine::sharedEngine()->playEffect("audio_effect_btn.wav");
            
            //还原样式设置
            this->m_selectedStyleIndex = 1;
            CCLabelTTF *labCurrStyleLabel = (CCLabelTTF*)this->getChildByTag(kRPGStartSceneLayerTagLabCurrStyle);
            labCurrStyleLabel->setString(this->m_styleData[this->m_selectedStyleIndex].second.c_str());
            
            //更新数据库
            RPGSaveData *saveDataObj = loadSaveData(&this->m_db);
            saveDataObj->m_windowStyle = this->m_styleData[this->m_selectedStyleIndex].first;
            saveData(&this->m_db, saveDataObj);
            
            //更新当前样式
            CCUserDefault::sharedUserDefault()->setStringForKey(GAME_STYLE, saveDataObj->m_windowStyle);
        }
            break;
        case kRPGStartSceneLayerTagSettingsStyleLeft:
        {
            //点击了样式选择的<<
            SimpleAudioEngine::sharedEngine()->playEffect("audio_effect_btn.wav");
            
            this->m_selectedStyleIndex--;
            if(this->m_selectedStyleIndex < 0)
                this->m_selectedStyleIndex = 0;
            
            CCLabelTTF *labCurrStyleLabel = (CCLabelTTF*)this->getChildByTag(kRPGStartSceneLayerTagLabCurrStyle);
            labCurrStyleLabel->setString(this->m_styleData[this->m_selectedStyleIndex].second.c_str());
            
            //更新数据
            RPGSaveData *saveDataObj = loadSaveData(&this->m_db);
            saveDataObj->m_windowStyle = this->m_styleData[this->m_selectedStyleIndex].first;
            saveData(&this->m_db, saveDataObj);
            
            //更新当前样式
            CCUserDefault::sharedUserDefault()->setStringForKey(GAME_STYLE, saveDataObj->m_windowStyle);
        }
            break;
        case kRPGStartSceneLayerTagSettingsStyleRight:
        {
            //点击了样式选择的>>
            SimpleAudioEngine::sharedEngine()->playEffect("audio_effect_btn.wav");
            
            this->m_selectedStyleIndex++;
            int max = (int)this->m_styleData.size() - 1;
            if(this->m_selectedStyleIndex > max)
                this->m_selectedStyleIndex = max;
            
            CCLabelTTF *labCurrStyleLabel = (CCLabelTTF*)this->getChildByTag(kRPGStartSceneLayerTagLabCurrStyle);
            labCurrStyleLabel->setString(this->m_styleData[this->m_selectedStyleIndex].second.c_str());
            
            //更新数据
            RPGSaveData *saveDataObj = loadSaveData(&this->m_db);
            saveDataObj->m_windowStyle = this->m_styleData[this->m_selectedStyleIndex].first;
            saveData(&this->m_db, saveDataObj);
            
            //更新当前样式
            CCUserDefault::sharedUserDefault()->setStringForKey(GAME_STYLE, saveDataObj->m_windowStyle);
        }
            break;
        default:
        {
            //开始游戏
            
            SimpleAudioEngine::sharedEngine()->playEffect("audio_start_btn.wav");
            this->goToMapScene();
        }
            break;
    }
    
}