void MenuLayerMainMenu::menuCallback(CCObject* pSender)
{
	CCLOG("menuCallback called");

	// get the userdata, it's the index of the menu item clicked
	CCMenuItem* pMenuItem = (CCMenuItem *)(pSender);
	int nIdx = pMenuItem->getZOrder() - 1000;

	// create the test scene and run it
	switch (nIdx)
	{
	case 1:
		{
			CCLOG("new game clicked");

			CCScene* scene=CCScene::create();
			CCLayer* layer=MenuLayerPlayerSelect::create();
			scene->addChild(layer,0);
			CCDirector::sharedDirector()->pushScene(CCTransitionSlideInT::create(1,scene));

			break;

		}
		
	case 2:
		CCLOG("load game clicked");
		break;

	case 6:
		CCDirector::sharedDirector()->end();
	default:
		break;
	}
}
Beispiel #2
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 FriendInvitationLayer::showInvitationCode(const char *invitationCode) {
    CCSprite *spInvitationBg = CCSprite::spriteWithFile("invitation_bg.png");
    spInvitationBg->setPosition(CCPointMake(320, 440));
    addChild(spInvitationBg);
    
    CCSprite *tempSprite1 = CCSprite::spriteWithSpriteFrameName("shareWeibo.png");
    CCSprite *tempSprite2 = CCSprite::spriteWithSpriteFrameName("shareWeibo.png");
    CCMenuItem *menuItemSina = CCMenuItemImage::itemFromNormalSprite(tempSprite1, 
                                                                     tempSprite2,
                                                                     this, 
                                                                     menu_selector(FriendInvitationLayer::inviteFriendFromWeibo));
    menuItemSina->setAnchorPoint(CCPointMake(0, 0));
    CCMenu *menu = CCMenu::menuWithItem(menuItemSina);
    menu->setPosition(CCPointMake(280, 505));
    addChild(menu);
    
    if(CGameData::Inst()->getLoginType() == enLoginReqType_TencentLogin){
        menuItemSina ->setIsVisible(CGameData::Inst()->getCommonInfo()->qq_voice_fg |CGameData::Inst()->getCommonInfo()->weixin_voice_fg);
        
    }else if(CGameData::Inst()->getLoginType() ==  enLoginReqType_SinaLogin){
        menuItemSina->setIsVisible(CGameData::Inst()->getCommonInfo()->sina_voice_fg |CGameData::Inst()->getCommonInfo()->weixin_voice_fg);
        
    }else {
        menuItemSina->setIsVisible(CGameData::Inst()->getCommonInfo()->sina_voice_fg|CGameData::Inst()->getCommonInfo()->qq_voice_fg |CGameData::Inst()->getCommonInfo()->weixin_voice_fg);
    }
    
    
    
    TextNode *lbInvitationCode = TextNode::textWithString(invitationCode, CCSizeMake(500, 40), CCTextAlignmentLeft, 32);
    lbInvitationCode->setColor(ccRED);
    lbInvitationCode->setPosition(CCPointMake(550, 646));
    addChild(lbInvitationCode);
}
Beispiel #4
0
CCMenuItem* CPullMachMenu::itemForTouchPM(CCTouch * touch)
{
	CCPoint touchLocation = touch->getLocation();

	if (m_pChildren && m_pChildren->count() > 0)
	{
		CCObject* pObject = NULL;
		CCARRAY_FOREACH(m_pChildren, pObject)
		{
			CCMenuItem* pChild = dynamic_cast<CCMenuItem*>(pObject);
			if (pChild && pChild->isVisible() && pChild->isEnabled())
			{
				CCPoint local = pChild->convertToNodeSpace(touchLocation);
				CCRect r;
				r.size = pChild->getContentSize();
				r.origin.x = r.size.width * 0.2f;
				r.size.width *= 0.6f;
				r.origin.y = r.size.height * 0.2f;
				r.size.height *= 0.8f;

				if (r.containsPoint(local))
				{
					return pChild;
				}
			}
		}
Beispiel #5
0
	bool UIScrollPage::dispatchTutorialMsg(CCObject* pObject,unsigned int type)
	{
		UIMenu* menu = NULL;
		CCMenuItem* menuItem = dynamic_cast<CCMenuItem*>(pObject);
		if(menuItem)
		{
			CCNode* node = menuItem->getParent();
			menu = dynamic_cast<UIMenu*>(node);			
		}
		else
		{
			menu = dynamic_cast<UIMenu*>(pObject);
		}

		if(menu)
		{
			CCNode* parent = menu->getParent();
			IconButton* button = dynamic_cast<IconButton*>(parent);
			char name[50];
			sprintf(name,"%s_%d",this->m_strName.c_str(),button->GetButtonIndex());
			return TutorialsManager::Get()->HandleOneEvent(name,type);
		}

		return true;
	}
Beispiel #6
0
CCMenuItem* CCMenuItem::create(CCObject *rec, SEL_MenuHandler selector)
{
    CCMenuItem *pRet = new CCMenuItem();
    pRet->initWithTarget(rec, selector);
    pRet->autorelease();
    return pRet;
}
Beispiel #7
0
LayerLevels::LayerLevels()
{
	CCPoint* offset = new CCPoint(180, 180);
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 3; j++) {
			CCMenuItemSprite* level = CCMenuItemSprite::create(
				CCSprite::createWithSpriteFrameName("btn_level1.png"), 
				CCSprite::createWithSpriteFrameName("btn_level2.png"), 
				this, menu_selector(LayerLevels::click_level));
			CCMenu* menu = CCMenu::createWithItem(level);
			menu->setPosition(CCDirector::sharedDirector()->convertToUI(
				ccp(offset->x + 200* i, offset->y + 85 * j)));
			this->addChild(menu);


			char str[64] = {0};
			sprintf(str, "%d", (j * 4 + i + 1));
			CCMenuItem* menuitem = new CCMenuItem();
			CCLabelTTF* text = CCLabelTTF::create(
				str, "Arial", 22);
			
			text->setColor(ccBLACK);
			menuitem->addChild(text);
			menu->addChild(menuitem);
		}
	}
}
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;
    }
}
Beispiel #9
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);}
void FrontCoverLayer::onClickedOneSever(CCObject* pSender)
{
	CCMenuItem* menuItem = dynamic_cast<CCMenuItem*>(pSender);
	if(menuItem)
	{
		CCNode* node = menuItem->getParent();
		CCMenu* menu = dynamic_cast<CCMenu*>(node);
		if(menu)
		{
			CCNode* parent = menu->getParent();
			IconButton* button = dynamic_cast<IconButton*>(parent);
			if(button)
			{
				int buttonIndex = button->GetButtonIndex();
				// to do
				SeverInfo* info = m_severList[buttonIndex];
				if(info)
				{
					USERINFO data = UserData::GetUserInfo();
					sprintf(data.ip,"%s",info->severIp);
					sprintf(data.lastServerName,"%s",info->name);
					data.port = info->port;
					UserData::SetUserInfo(data);
					//onCLickedSeverCloseBt(pSender);
					XLogicManager::sharedManager()->logIn();
				}
			}
		}
	}
}
Beispiel #11
0
//设置按钮显示
void CStar97UILayer::setBtnVisible(enGameBtnTag eBtnTag, bool bVisible)
{
	CCMenuItem * pItem = dynamic_cast<CCMenuItem *>(m_pMenuLayer->getChildByTag(eBtnTag));
	CCAssert(pItem != NULL, "this tag button don't have");
	if (pItem->isVisible() != bVisible)
		pItem->setVisible(bVisible);
}
Beispiel #12
0
void CityListLayer::onPressCityBtn(CCObject* sender)
{
	if (playerMoving)
	{
		return;
	}

	CCMenuItem* menuItem = dynamic_cast<CCMenuItem*>(sender);
	if(menuItem)
	{
		CCNode* node = menuItem->getParent();
		CCMenu* menu = dynamic_cast<CCMenu*>(node);
		if(menu)
		{
			CCNode* parent = menu->getParent();
			IconButton* button = dynamic_cast<IconButton*>(parent);
			if(button)
			{
				playerMoving = true;
				int index = button->GetButtonIndex();	

				targetCityId = cityInfoList[index - 1].cityId;
				moveToCity(targetCityId, 0);
							
			}
		}
	}
}
Beispiel #13
0
//------------------------------------------------------------------
//
// NodeToWorld
//
//------------------------------------------------------------------
NodeToWorld::NodeToWorld()
{
	//
	// This code tests that nodeToParent works OK:
	//  - It tests different anchor Points
	//  - It tests different children anchor points

	CCSprite *back = CCSprite::spriteWithFile(s_back3);
	addChild( back, -10);
	back->setAnchorPoint( CCPointMake(0,0) );
	CCSize backSize = back->getContentSize();
	
	CCMenuItem *item = CCMenuItemImage::itemFromNormalImage(s_PlayNormal, s_PlaySelect);
	CCMenu *menu = CCMenu::menuWithItems(item, NULL);
	menu->alignItemsVertically();
	menu->setPosition( CCPointMake(backSize.width/2, backSize.height/2));
	back->addChild(menu);
	
	CCActionInterval* rot = CCRotateBy::actionWithDuration(5, 360);
	CCAction* fe = CCRepeatForever::actionWithAction( rot);
	item->runAction( fe );
	
	CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(200,0));
	CCActionInterval* move_back = move->reverse();
	CCFiniteTimeAction* seq = CCSequence::actions( move, move_back, NULL);
	CCAction* fe2 = CCRepeatForever::actionWithAction((CCActionInterval*)seq);
	back->runAction(fe2);
}
Beispiel #14
0
//------------------------------------------------------------------
//
// NodeToWorld
//
//------------------------------------------------------------------
NodeToWorld::NodeToWorld()
{
    //
    // This code tests that nodeToParent works OK:
    //  - It tests different anchor Points
    //  - It tests different children anchor points

    CCSprite *back = CCSprite::create(s_back3);
    addChild( back, -10);
    back->setAnchorPoint( ccp(0,0) );
    CCSize backSize = back->getContentSize();
    
    CCMenuItem *item = CCMenuItemImage::create(s_PlayNormal, s_PlaySelect);
    CCMenu *menu = CCMenu::create(item, NULL);
    menu->alignItemsVertically();
    menu->setPosition( ccp(backSize.width/2, backSize.height/2));
    back->addChild(menu);
    
    CCActionInterval* rot = CCRotateBy::create(5, 360);
    CCAction* fe = CCRepeatForever::create( rot);
    item->runAction( fe );
    
    CCActionInterval* move = CCMoveBy::create(3, ccp(200,0));
    CCActionInterval* move_back = move->reverse();
    CCSequence* seq = CCSequence::create( move, move_back, NULL);
    CCAction* fe2 = CCRepeatForever::create(seq);
    back->runAction(fe2);
}
Beispiel #15
0
void MapMenu::addMenu()
{
    if (spriteBackButton != NULL) {
        spriteBackButton->removeFromParentAndCleanup(false);
    }
    spriteBackButton = CCSprite::create("Background_Estacionamento_botoes.png");
    spriteBackButton->setAnchorPoint(ccp(0, 0));
	CCSize winsize = CCDirector::sharedDirector()->getWinSize();
    
    if (winsize.height > 480) {
        spriteBackButton->setPosition(ccp(0, 430));
    }
    else
    {
        spriteBackButton->setPosition(ccp(0, 350));
    }
    
    layer->addChild(spriteBackButton, 100) ;
    
    
    
    CCMenuItem *pOpenMapItem;
    CCMenuItem *pOpen3DItem;
    if(type == MAP_NORMAL )
    {
        pOpenMapItem = CCMenuItemImage::create("button_comochegar_pressed.png","button_comochegar_pressed.png",this,menu_selector(MapMenu::openMap));
        pOpen3DItem = CCMenuItemImage::create("button_3d_on.png","button_3d_on.png",this,menu_selector(MapMenu::open3D));
        
    }
    else
    {
        pOpenMapItem = CCMenuItemImage::create("button_comochegar_on.png","button_comochegar_on.png",this,menu_selector(MapMenu::openMap));
        pOpen3DItem = CCMenuItemImage::create("button_3d_pressed.png","button_3d_pressed.png",this,menu_selector(MapMenu::open3D));
        
    }
    
      pOpenMapItem->setAnchorPoint(ccp(0, 0));
	pOpenMapItem->setPosition(ccp(0, 0));
    pOpen3DItem->setAnchorPoint(ccp(0, 0));
	pOpen3DItem->setPosition(ccp(110, 00));
    
    //  pCloseItem->setFontSize(35);
    // pCloseItem->setFontName("Helvetica");
    if (menu != NULL) {
    menu->removeFromParentAndCleanup(false);
    }
    menu = CCMenu::create(pOpenMapItem,pOpen3DItem,NULL);
    menu->setAnchorPoint(ccp(0, 0));
    
    if (winsize.height > 480) {
       menu->setPosition(ccp(50, 450));
    }
    else
    {
        menu->setPosition(ccp(50, 360));
    }

	
	layer->addChild(menu,101);
}
Beispiel #16
0
void CCBProxy::setCallback(CCNode* pNode,int nHandle,int nControlEvents)
{
    if (NULL == pNode) {
        return;
    }
    
    if (NULL != dynamic_cast<CCMenuItem*>(pNode))
    {
        CCMenuItem *pMenuItem = dynamic_cast<CCMenuItem*>(pNode);
        if (NULL != pMenuItem) {
            pMenuItem->registerScriptTapHandler(nHandle);
        }
    }
    else  if (NULL != dynamic_cast<CCControl*>(pNode))
    {
        
        CCControl* pControl = dynamic_cast<CCControl*>(pNode);
        if (NULL != pControl)
        {
            for (int i = 0; i < kControlEventTotalNumber; i++)
            {
                if ((nControlEvents & (1 << i)))
                {
                    pControl->addHandleOfControlEvent(nHandle, 1 << i);
                }
            }
        }
    }
}
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;
    }
    
}
Beispiel #18
0
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();
    }
}
Beispiel #19
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);
}
void CChooseLetterWindow::LetterBtnClick(Object* sender)
{	
	if(!m_ChoosenLetter)
	{
		return;
	}
	CCMenuItem * button = (CCMenuItem*) sender;
	m_ChoosenLetter->SetLetter((char)button->getTag());
	Hide();
}
Beispiel #21
0
void RadioMenu::onTouchMoved(Touch* touch, Event* event)
{
	CCMenuItem *curSelection = this->getItemForTouch(touch);
    if (curSelection != _curHighlighted && curSelection != NULL) {
        _curHighlighted->unselected();
        curSelection->selected();
        _curHighlighted = curSelection;
        return;
    }
}
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();
}
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);
		}
}
Beispiel #24
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);
    }
}
Beispiel #25
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));
}
Beispiel #26
0
CCMenuItem* MyMenu::itemForTouch(CCTouch *touch) {
    CCPoint touchLocation = touch->getLocationInView();
    touchLocation = CCDirector::sharedDirector()->convertToGL(touchLocation);
    if (m_pChildren && m_pChildren->count() > 0)
    {
        CCObject* pObject = NULL;
        CCARRAY_FOREACH(m_pChildren, pObject)
        {
            CCMenuItem* pChild = dynamic_cast<CCMenuItem*>(pObject);
            if (pChild && pChild->isVisible() && ((CCMenuItem*)pChild)->isEnabled())
            {
                if (dynamic_cast<MyTiledMenuItemSprite*>(pChild) != NULL){
                    CCPoint posiT = map->transMapToTiled(this->getPosition());
                    
                    CCPoint tiled = map->transMapToTiled(map->convertToNodeSpace(touchLocation));
                    if (contentSizeByTiled.width == 1 && contentSizeByTiled.height == 1) {
                        CCPoint local = pChild->convertToNodeSpace(touchLocation);
                        CCRect r = ((CCMenuItem*)pChild)->rect();
                        r.origin = CCPointZero;
                        if (r.containsPoint(local))
                        {
                            //物体碰撞系统参数,上面是地形碰撞系统
//                            ((MyMap*)map)->initTip(this->getPosition(), contentSizeByTiled.width);
//                            ((MyMap*)map)->cancelAllBuilding();
//                            ((MyMap*)map)->moveTemp  = this;
                            cacheLoc = this->getPosition();
                            return (CCMenuItem*)pChild;
                        }
                    } else {
                        if(Mathlib::inBound(tiled.x, posiT.x+contentSizeByTiled.width/2, posiT.x-contentSizeByTiled.width/2) &&
                           Mathlib::inBound(tiled.y, posiT.y+contentSizeByTiled.height/2, posiT.y-contentSizeByTiled.height/2)) {
                            cacheLoc = this->getPosition();
//                            ((MyMap*)map)->initTip(this->getPosition(), contentSizeByTiled.width);
//                            ((MyMap*)map)->cancelAllBuilding();
//                            ((MyMap*)map)->moveTemp  = this;
                            return (CCMenuItem*)pChild;
                        }
                    }
                } else {
                    CCPoint local = pChild->convertToNodeSpace(touchLocation);
                    CCRect r = ((CCMenuItem*)pChild)->rect();
                    r.origin = CCPointZero;
                    if (r.containsPoint(local))
                    {
                        //物体碰撞系统参数,上面是地形碰撞系统
                        //TODO
//                        ((MyMap*)map)->moveTemp  = this;
                        cacheLoc = this->getPosition();
                        return (CCMenuItem*)pChild;
                    }
                }
            }
        }
bool HSGoldInadequateDialog::InitDialog()
{
	CCSprite* pBackground = CCSprite::create("Image/SelectChannel/goumaijinbidikuang.png");
	pBackground->setPosition(ccp(307,480));
	this->addChild(pBackground);


	CCSprite* pGoldFrame = CCSprite::create("Image/SelectChannel/Mingziditu.png");
	pGoldFrame->setPosition(ccp(236,202));
	pBackground->addChild(pGoldFrame);

	CCSprite* pMoneyFrame = CCSprite::create("Image/SelectChannel/Mingziditu.png");
	pMoneyFrame->setPosition(ccp(520,202));
	pBackground->addChild(pMoneyFrame);

	const message::PropInfoData* pPropInfodata = HS_GAME_CACHE()->GetPropInfoData();

	for (int i =0;i<pPropInfodata->buygoldlist_size();++i)
	{
		int temp = pPropInfodata->buygoldlist(i).gold_number();
		if ((int)m_buyGold.gold_number() < temp)
		{
			m_buyGold = pPropInfodata->buygoldlist(i);
		}
		if (temp > HS_GAME_CACHE()->GetGold())
		{
			m_buyGold = pPropInfodata->buygoldlist(i);
			break;
		}
	}


	CCLabelTTF* pGoldTTF = CCLabelTTF::create(CCString::createWithFormat("%d",m_buyGold.gold_number())->getCString(),HS_FONT_HuaKang,36.f);
	pGoldTTF->setAnchorPoint(HS_ANCHOR_L_CENTER);
	pGoldTTF->setPosition(ccp(0,pGoldTTF->getContentSize().height - pGoldTTF->getFontSize() / 2.f));
	pGoldFrame->addChild(pGoldTTF);

	CCLabelTTF* pMoneyTTF = CCLabelTTF::create(CCString::createWithFormat("%d",m_buyGold.money())->getCString(),HS_FONT_HuaKang,36.f);
	pMoneyTTF->setAnchorPoint(HS_ANCHOR_L_CENTER);
	pMoneyTTF->setPosition(ccp(0,pMoneyTTF->getContentSize().height - pMoneyTTF->getFontSize() / 2.f));
	pMoneyFrame->addChild(pMoneyTTF);

	CCMenuItem* pGoRoomItem = CCMenuItemImage::create("Image/SelectChannel/dibeilvchang_01.png","Image/SelectChannel/dibeilvchang_02.png",this,menu_selector(HSGoldInadequateDialog::Call_GoRoom));
	pGoRoomItem->setPosition(ccp(169,322));
	this->PushMenu(pGoRoomItem);

	CCMenuItem* pBuyItem = CCMenuItemImage::create("Image/SelectChannel/goumai_01.png","Image/SelectChannel/goumai_02.png",this,menu_selector(HSGoldInadequateDialog::Call_Buy));
	pBuyItem->setPosition(ccp(456,322));
	this->PushMenu(pBuyItem);


	return true;
}
Beispiel #28
0
void GameMenuLayer::menuCallback(CCObject* pSender)
{
	CCMenuItem* menuItem = (CCMenuItem*)(pSender);
	int nIdx = menuItem->getZOrder()-1000;

	if (nIdx == GAME_MENU_START)
	{
		GameScene* pScene = new GameScene();
		pScene->runThisTest();
		pScene->release();
	}
}
Beispiel #29
0
void CCMenuItemToggle::setIsEnabled(bool enabled)
{
    CCMenuItem::setIsEnabled(enabled);
    
    if(m_pSubItems && m_pSubItems->count() > 0)
    {
        CCObject* pObj = NULL;
        CCARRAY_FOREACH(m_pSubItems, pObj)
        {
            CCMenuItem* pItem = (CCMenuItem*)pObj;
            pItem->setIsEnabled(enabled);
        }
Beispiel #30
0
	void CCMenuItemToggle::setSelectedIndex(unsigned int index)
	{
		if( index != m_uSelectedIndex )
		{
			m_uSelectedIndex = index;
			this->removeChildByTag(kCurrentItem, false);
			CCMenuItem *item = m_pSubItems->getObjectAtIndex(m_uSelectedIndex);
			this->addChild(item, 0, kCurrentItem);
			CGSize s = item->getContentSize();
			this->setContentSize(s);
			item->setPosition( ccp( s.width/2, s.height/2 ) );
		}
	}