Exemple #1
0
void CStoreLayer::CanleCallback( CCObject* pSender )
{
	CCMenuItemSprite* pItem = ( CCMenuItemSprite* )pSender;

	switch ( pItem->getTag() )
	{
	case TOWRMBTAG:
		{
			CallJni::forGet1Goal();
		}
		break;
	case FOURRMBTAG:
		{
			CallJni::forGet5Goal();
		}
		break;
	case SIXRMBTAG:
		{
			CallJni::forGet10Goal();
		}
		break;
	case CANLETAG:
		this->removeFromParent();
		break;
	default:
		break;
	}
}
void CCLayerParent::quirkButtonTapped(CCObject* obj) {    
   //CCLog("Quirk button tapped!");
	 CCMenuItemSprite * item = ( CCMenuItemSprite * )obj;
	 
 	int index = item->getTag();
	CCLog("%d button tapped!",index);
    if(!decks[index].cooldown) return;
   PlayerComponent* humanPlayer = _humanPlayer->player();
	if(!_playerSystem->handleEconomic(humanPlayer,&decks[index])) return;

   if(decks[index].cooldown)
   {
	   decks[index].cooldown = false;
	   decks[index].potentio->setValue(0.1f);
	   decks[index].potentio->setVisible(true);
   }


       CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("spawn.wav");
	Entity* entity = _entityFactory->createMonsterWithTeam(MonsterType(index),1);
	RenderComponent* render =entity->render();
	if (render) {        
	    CCSize winSize = CCDirector::sharedDirector()->getWinSize();
	    float randomOffset = CCRANDOM_X_Y(-winSize.height * 0.25, winSize.height * 0.25);
	    render->node->setPosition ( ccp(winSize.width * 0.25, winSize.height * 0.5 + randomOffset));
			
	}
}
void PauseLayer::menuCallBack(CCObject *menuItem) {
    Utility::playSound(CCString::create(kSoundForButtonClick), 1);
    CCMenuItemSprite *sprite = ((CCMenuItemSprite*)(menuItem));
    int tag = sprite->getTag();
    switch (tag) {
        case 1:
            CCLOG("newgame");
            CCDirector::sharedDirector()->getTouchDispatcher()->removeDelegate(gLayer);
            CCDirector::sharedDirector()->resume();
            CCDirector::sharedDirector()->replaceScene(GameScene::create(kSceneTypeGameScene));
            break;
        case 2:
            CCLOG("menuscreen");
            CCDirector::sharedDirector()->getTouchDispatcher()->removeDelegate(gLayer);
            CCDirector::sharedDirector()->resume();
            CCDirector::sharedDirector()->replaceScene(MainMenuScene::create());
            break;
            
        case 3:
            CCLOG("resume");
            showHUDButtons();
            CCDirector::sharedDirector()->resume();
            gLayer->hudLayer->pauseBtnMenu->setVisible(true);
            removeFromParent();
            break;
        case 4:
            CCLOG("sound");
            break;
        case 5:
            CCLOG("records");
//            if (arrayForActive != NULL) {
//                arrayForActive->removeAllObjects();   
//            }
            removeChild(objectiveLayer, true);
            addStatsLayer();
            break;
        case 6:
            CCLOG("objective");
            removeChild(statsLayer, true);
            addObjectiveLayer();
            break;
            
            case 7:
            CCLog("this game");
            isCallFromRecords = false;
            removeChild(statsLayer, true);
            addStatsLayer();
            break;
            case 8:
            CCLog("records");
            isCallFromRecords = true;
            removeChild(statsLayer, true);
            addStatsLayer();
            break;
        default:
            break;
    }
    
}
void MainLayerZhuangBeiBaseBody::itemImageClicked(CCObject* obj)
{
    if (mFooterForPop == NULL)
    {
        CCLog("please call setFooter!");
        CCAssert(false,"");
        return;
    }

    CCMenuItemSprite* item = (CCMenuItemSprite*)obj;
//	CCLog("Image Clicked! index = %d",item->getTag());
    mClickedIdx = item->getTag();

    EquipmentXiangQingBody* xiangQing = new EquipmentXiangQingBody(mEquipmentVec[item->getTag()]
            , mEquipmentVec[item->getTag()]->getActorId(),mFrom);
    mFooterForPop->popUpContaintLayer(xiangQing, Pop_Pos_WondowDown);
    xiangQing->release();
}
Exemple #5
0
void LayerGoods::menuCallbackBuy(CCObject* pSender)
{
	if (pSender)
	{
		Topwo::getInstance()->getTopwoAudio()->playEffect(1);
	}

	if (!pSender)
	{
		return;
	}
	TopwoTools *tl = Topwo::getInstance()->getTopwoTools();
	UserInfo *user_info = Topwo::getInstance()->getTopwoData()->getUserInfo();

	CCMenuItemSprite* item = static_cast<CCMenuItemSprite*>(pSender);
	int tag = item->getTag();
	CCSprite* sprite = static_cast<CCSprite*>(this->getChildByTag(tag));
	CCLabelAtlas* la = static_cast<CCLabelAtlas*>(sprite->getChildByTag(2));
	int need_gold = atoi(la->getString());
	int cur_gold = user_info->getCurrentGold();
	if (need_gold > cur_gold)
	{//金币不足
		this->addChild(LayerHint::createWith(CCLabelTTF::create(CCString::createWithFormat("%s%s", tl->getXmlString("Gold")->getCString(), tl->getXmlString("HintNotEnough")->getCString())->getCString(), "", 30), 2, this, callfuncN_selector(LayerGoods::hintCallbackWork)), 10);
		return;
	}
	user_info->setCurrentGold(cur_gold - need_gold);
	if (tag == 1)
	{
		user_info->setCurrentGoodsLevelTiPo(user_info->getCurrentGoodsLevelTiPo() + 1);
		user_info->setCurrentTiPoBonus(getGoodsBonus(user_info->getCurrentGoodsLevelTiPo()) * 0.01f);
	}
	else if (tag == 2)
	{
		user_info->setCurrentGoodsLevelMeiLi(user_info->getCurrentGoodsLevelMeiLi() + 1);
		user_info->setCurrentMeiLiBonus(getGoodsBonus(user_info->getCurrentGoodsLevelMeiLi()) * 0.01f);
	}
	else if (tag == 3)
	{
		user_info->setCurrentGoodsLevelZhiLi(user_info->getCurrentGoodsLevelZhiLi() + 1);
		user_info->setCurrentZhiLiBonus(getGoodsBonus(user_info->getCurrentGoodsLevelZhiLi()) * 0.01f);
	}
	else if (tag == 4)
	{
		user_info->setCurrentGoodsLevelEQ(user_info->getCurrentGoodsLevelEQ() + 1);
		user_info->setCurrentEQBonus(getGoodsBonus(user_info->getCurrentGoodsLevelEQ()) * 0.01f);
	}
	else if (tag == 5)
	{
		user_info->setCurrentGoodsLevelGanXing(user_info->getCurrentGoodsLevelGanXing() + 1);
		user_info->setCurrentGanXingBonus(getGoodsBonus(user_info->getCurrentGoodsLevelGanXing()) * 0.01f);
	}

	updateMe();
}
Exemple #6
0
void FairyMenu::fairyMenuCallback(CCObject* sender){
	CCMenuItemSprite* itemSprite = (CCMenuItemSprite *)sender;
	int itemTag = itemSprite->getTag();
	SimpleAudioEngine::sharedEngine()->end();
	CCScene* pScene = FairyTitle::scene();
	switch(itemTag){
	case 1:
		CCDirector::sharedDirector()->replaceScene(pScene);
		break;
	case 3:
		CCDirector::sharedDirector()->end();
		break;
	}
}
void S65ShowVideo::S15DetailCallback(CCObject* pSender)
{
    if (isMenuLock == false)
    {
       // showStrUrlMap = PersonalApi::getRealGroupStringMap(plistDic,"S15VideoIntro","videoIntro");
        
        CCMenuItemSprite *aItem = (CCMenuItemSprite *)pSender;
        AppDelegate::S151DetailSelected = aItem->getTag()-btnTag;
        
        webView_top = (SPWebView *)SPWebView::create();
        webView_top->setTag(1);
        CCRect rect;
        
        if (webView_top->getScreenWidthSize()==1)
        {
            rect= CCRect(origin.x+70/2, origin.y+475/2, visibleSize.width-130/2,visibleSize.height-590/2);
        }
        else
        {
            rect= CCRect(origin.x+70, origin.y+475, visibleSize.width*2-130,visibleSize.height*2-590);
        }
        
        
        const char * picIntr = showStrUrlMap[PersonalApi::convertIntToString(AppDelegate::S151DetailSelected-1)].c_str();
        if (1 == (int)showPicMap.size()/4+1)
        {
            picIntr = showStrUrlMap[PersonalApi::convertIntToString(AppDelegate::S151DetailSelected+2)].c_str();
        }
        webView_top->addWebViewWithCloseButton(picIntr, rect);
        this->addChild(webView_top);
        
        const char * imageName = "S31Back.png";
        backItemImage = CCMenuItemImage::create(imageName,
                                                imageName,
                                                this,
                                                menu_selector(Main::removeVideo));
        
        backItemImage->setPosition(ccp(960,550));
        CCMenu * backMenu = CCMenu::create(NULL);
        backMenu ->setPosition(CCPointZero);
        _menu->addChild(backItemImage,zNum);
        
        
    }
}
void S22PicDetail::S2menuCallback(CCObject* pSender)
{
    CCMenuItemSprite *aItem = (CCMenuItemSprite *)pSender;
    
    switch (aItem->getTag())
    {
        case btnTag:
            ;
            break;
        case btnTag+1:
            //newScene->addChild(S13News::create());
            
            break;
            
        default:
            break;
    }
}
Exemple #9
0
void S132Detail::moreMenuCallback(CCObject* pSender)
{
    CCMenuItemSprite *aItem = (CCMenuItemSprite *)pSender;
    CCScene *newScene = CCScene::create();
    switch (aItem->getTag())
    {
        case btnTag:
            newScene->addChild(S13News::create());
            
            break;
        case btnTag+1:
            // newScene->addChild(S3TestMain::create());
            
            break;
            
        default:
            break;
    }
    CCDirector::sharedDirector()->replaceScene(CCTransitionSlideInR::create(0.0f, newScene));     
}
Exemple #10
0
void S6PeiXun::menuCallback(CCObject* pSender)
{
    removeUIKit();
    CCUIKit::removeTextView(1);
    CCMenuItemSprite *aItem = (CCMenuItemSprite *)pSender;
    CCScene *newScene = CCScene::create();
    AppDelegate::S2Alpha = 0.0;
    AppDelegate::S6SelectNavi = aItem->getTag()-btnTag;
    
    if(AppDelegate::S6SelectNavi ==9)
    {
        newScene->addChild(S65ShowVideo::create());
    }
    else
    {
        newScene->addChild(S61Detail::create());
    }
    
    CCDirector::sharedDirector()->replaceScene(CCTransitionFade::create(0.0, newScene));//¶¯»­¹ý³¡
}
Exemple #11
0
bool SlidingMenuGrid::initWithArray(CCArray *items, int cols, int rows, CCPoint pos , CCPoint pad, bool vertical, float threshold)
{
	if( !CCLayer::init() )
	{
		return false;
	}
    
	selectedItem = NULL;
	setTouchEnabled(true);
    CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this,0,true);
	pMenu=new CCMenu;
	addChild(pMenu,0);
    
    CCObject *object;
    CCMenuItemSprite *getItem;
    
    CCARRAY_FOREACH(items, object)
    {
        getItem = (CCMenuItemSprite*)object;
        pMenu->addChild(getItem, 1, getItem->getTag());
    }
Exemple #12
0
void S4HeZuo::menuCallback(CCObject* pSender)
{
    removeUIKit();
    AppDelegate::isTextViewExist = true;
    textView->removeTextView(1);
     
    CCMenuItemSprite *aItem = (CCMenuItemSprite *)pSender;
    CCScene *newScene = CCScene::create();
    AppDelegate::S2Alpha = 0.0;
    AppDelegate::S4SelectNavi = aItem->getTag()-btnTag;
    
    if(AppDelegate::S4SelectNavi ==9)
    {
        newScene->addChild(S45ShowVideo::create());
	//CCMessageBox("no video", "no video");
    }
    else
    {
        newScene->addChild(S41Detail::create());
    }
    
    CCDirector::sharedDirector()->replaceScene(CCTransitionFade::create(0.0f, newScene));
}
Exemple #13
0
void CWaterpump::onSelectedMenuItem(cocos2d::CCObject *pSender)
{
    // 条件判定, 斧子是否还有
    if (NULL != m_pSelectedItem)
    {
        m_pSelectedItem->unselected();
    }

    CCMenuItemSprite *pSelected = dynamic_cast<CCMenuItemSprite*>(pSender);
    int nAxeType = pSelected->getTag();
    int nRemainAxe = CPlayerAccount::GetAccountInstance()->GetAccountPropsNum(nAxeType);
    if (nRemainAxe > 0 && m_pSelectedItem != pSelected)
    {
        CCNotificationCenter::sharedNotificationCenter()->postNotification(MSG_UICHANGEAXE, pSender);
        m_pSelectedItem = pSelected;
    }
    else
    {
        CCNotificationCenter::sharedNotificationCenter()->postNotification(MSG_UICHANGEAXE, m_pNormalAxeItem);
        m_pSelectedItem = m_pNormalAxeItem;
    }

    m_pSelectedItem->selected();
}
Exemple #14
0
void TableBar::menuselect(CCObject* pSender)
{
    CCMenuItemSprite * aItem = (CCMenuItemSprite *)pSender;
    string className = itemTitleVec[aItem->getTag()];
 
    CCScene *newScene = CCScene::create();

    if(className.find("GRE模考")!= string::npos)
    {
        newScene->addChild(S1Main::create());
    }
    else if (className.find("备考资料")!= string::npos)
    {
        newScene->addChild(S11PrepareRes::create());
    }
    else if (className.find("设置")== string::npos)
    {
        newScene->addChild(pSetting::create());
    }
    
    resetSceneArgument();
    
    CCDirector::sharedDirector()->replaceScene(CCTransitionSlideInR::create(0.0, newScene));
}
Exemple #15
0
void PlayScene::chooseEdgeEnded(cocos2d::CCObject *pSender)
{
  sound::playSoundFx(SFX_TOUCH_POP);
  CCMenuItemSprite* pop = (CCMenuItemSprite*)pSender;
  pop->setVisible(false);
  CCSprite *edge = CCSprite::create("Images/Game/Object/edge.png");
  
  TileInfo *tileInfo = mTileInfoVector.at(mCurTile);

//  CCSprite *sp = tileInfo->getTile();
  CCLog("curTile = %d", mCurTile);
  
  if (pop->getTag() == TAG_EDGE_BOTTOM)
  {
    addBottomEdge(tileInfo, edge);
  }
  else if (pop->getTag() == TAG_EDGE_TOP)
  {
    addTopEdge(tileInfo, edge);
  }
  else if (pop->getTag() == TAG_EDGE_LEFT)
  {
    addLeftEdge(tileInfo, edge);
  }
  else if (pop->getTag() == TAG_EDGE_RIGHT )
  {
    addRightEdge(tileInfo, edge);
  }
  tileInfo->setNumberEdgeAvailale(tileInfo->getNumberEdgeAvailale()-1);
  CCLog("tileInfo->getNumberEdgeAvailale() = %d", tileInfo->getNumberEdgeAvailale());
  
  CCLog("Current Player is %i", GameManager::getCurrentPlayer());
  
  bool checkIncreasingScore = false;
  
  for (int i = 0; i < mTileInfoVector.size(); ++i)
  {
    if (mTileInfoVector.at(i)->getNumberEdgeAvailale() == 0 && mTileInfoVector.at(i)->getBelongToPlayer() == 0 && mTileInfoVector.at(i)->getHasTree() == false && mTileInfoVector.at(i)->getHasStone() == false)
    {
      GameManager::increaseScore(GameManager::getCurrentPlayer());
      checkIncreasingScore = true;
      sprintf(mScoreBuffer, "%i", GameManager::getPlayerScore(GameManager::getCurrentPlayer()));
      if (GameManager::getCurrentPlayer() == PLAYER_ONE)
      {
        mTileInfoVector.at(i)->setBelongToPlayer(1);
        mTileInfoVector.at(i)->getTile()->setColor(ccBLUE);
        mLbnScorePlayer1->setString(mScoreBuffer);
      }
      else
      {
        mTileInfoVector.at(i)->setBelongToPlayer(2);
        mTileInfoVector.at(i)->getTile()->setColor(ccRED);
        mLbnScorePlayer2->setString(mScoreBuffer);
      }
      if (mTileInfoVector.at(i)->getHasAxe())
      {
        sound::playSoundFx(SFX_PICKUP_AXE);
        GameManager::increaseNumOfAxes(GameManager::getCurrentPlayer());
        CCLog("axe collected");
      }
    }
  }
  
  if (!checkIncreasingScore)
  {
    if (GameManager::getCurrentPlayer() == PLAYER_ONE)
    {
      mPlayerOneShadow->setVisible(false);
      mPlayerTwoShadow->setVisible(true);
    }
    else
    {
      mPlayerTwoShadow->setVisible(false);
      mPlayerOneShadow->setVisible(true);
    }
    
    GameManager::changeCurrentPlayer();
  }
   
  removePopups();
}
void FairyControlPanel::fairyMenuCallback(CCObject* sender){
	CCMenuItemSprite* buttonSprite = (CCMenuItemSprite *)sender;
	int buttonTag = buttonSprite->getTag();
	FairyMain* parent = static_cast<FairyMain *>(this->getParent());
	parent->doClickButton(buttonTag);
}