void MainLayerHerosBaseBody::disableAllTouchBegin() { mTableView->setTouchEnabled(false); int cellNum = numberOfCellsInTableView(mTableView); for (int i=0;i<cellNum;i++) { CCTableViewCell* cell = mTableView->cellAtIndex(i); if (cell) { CCNode* bg = cell->getChildByTag(TAG_BaseBody_TABLE_ITEM); if (bg) { CCMenu* menu = (CCMenu*)bg->getChildByTag(TAG_BaseBody_TABLE_HERO_IMG); if (menu) { menu->setEnabled(false); } menu = (CCMenu*)bg->getChildByTag(TAG_Menu); if(menu) { menu->setEnabled(false); } } } } }
void MainLayerZhuangBeiBaseBody::disableAllTouchEnd() { mTableView->setTouchEnabled(true); int cellNum = numberOfCellsInTableView(mTableView); for (int i=0; i<cellNum; i++) { CCTableViewCell* cell = mTableView->cellAtIndex(i); if (cell) { CCNode* bg = cell->getChildByTag(TAG_EquipBaseBody_TABLE_ITEM); if (bg) { CCMenu* menu = (CCMenu*)bg->getChildByTag(TAG_BaseBody_MENU); if (menu) { menu->setEnabled(true); } } } } CCPoint beg = mTableView->getContentOffset(); if (mOffset.y < beg.y) mOffset.y = beg.y; if (mOffset.y > tableCellSizeForIndex(mTableView,0).height*3) mOffset.y = tableCellSizeForIndex(mTableView,0).height*3; mTableView->setContentOffset(mOffset); }
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; } }
// 恢复逻辑 void PauseLayer::play_logic( CCObject* pSender){ CCLOG("点击恢复"); GamingLayer* fatherNode = (GamingLayer*)getParent(); // 1. 将这个暂停层进行移植 fatherNode->removeChildByTag( 99, true ); // 2. 设定CCMenu(父节点中)enable 为true CCMenu* menu = (CCMenu*) fatherNode->getChildByTag( 156 ); menu->setEnabled( true ); fatherNode->mWarrior->setTouchEnabled( true ); // 3.调用 CCDirector 的 resume 方法 CCDirector::sharedDirector()->resume(); // 4.恢复背景音乐 SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic(); setTouchEnabled( true ); }
void MainGameScene::returnMainGame() { setTouchEnabled(true); CCMenu* resumeDialog = (CCMenu*)this->getChildByTag(tagResumeDialog); if(resumeDialog){ resumeDialog->setOpacity(0); resumeDialog->setEnabled(false); } }
void GameMain::setover() { CCMenu* pMenu = (CCMenu *)this->getChildByTag(25); pMenu->setVisible(true); pMenu->setEnabled(true); gameover->setVisible(true); gameover->setScale(0); pMenu->setScale(0); pMenu->runAction(CCScaleTo::create(0.5,1)); gameover->runAction(CCScaleTo::create(0.5,0.5)); isover = true; }
void LevelSelectScene::hiddenStartMenu() { CCMenu* startMenu = (CCMenu*)this->getChildByTag(tagStartMenuDialog); if(startMenu){ this->removeChild(startMenu); } CCMenu* levelSelectMenu = (CCMenu*)this->getChildByTag(tagLevelSelectMenuDialog); if(levelSelectMenu){ levelSelectMenu->setOpacity(255); levelSelectMenu->setEnabled(true); } }
void MainGameScene::makeRetryButton() { CCSize winSize = CCDirector::sharedDirector()->getWinSize(); CCMenuItemImage* retryItem = CCMenuItemImage::create("menu_waku.png","menu_waku.png" ,this, menu_selector(MainGameScene::showResumeDialog)); retryItem->setScale(0.5); CCSize pRetryItemSize = retryItem->getContentSize(); retryItem->setPosition(ccp( pRetryItemSize.width * 0.4, winSize.height - pRetryItemSize.height * 0.4)); CCMenu* retryButton = CCMenu::create(retryItem,NULL); retryButton->setPosition(CCPointZero); retryButton->setTag(tagRetryButton); retryButton->setEnabled(false); this->addChild(retryButton); }
void GameMainLayer::setOver() { //游戏结束 CCMenu *pMenu = (CCMenu *)this->getChildByTag(25); pMenu->setVisible(true); pMenu->setEnabled(true); pMenu->setScale(0); pMenu->runAction(CCScaleTo::create(0.5f, 1)); gameOver->setVisible(true); gameOver->setScale(0); gameOver->runAction(CCScaleTo::create(0.5f, 0.5f)); this->isOver = true; }
void MainGameScene::makeClearDaialog() { CCSize winSize = CCDirector::sharedDirector()->getWinSize(); CCMenuItemImage* titleItem = CCMenuItemImage::create("logo_menu.png","logo_menu.png" ,this, menu_selector(MainGameScene::tapTitleButton)); titleItem->setPosition(ccp(winSize.width * 0.3, winSize.height * 0.3)); CCMenuItemImage* retryItem = CCMenuItemImage::create("logo_restart.png","logo_restart.png" ,this, menu_selector(MainGameScene::tapRetryButton)); retryItem->setPosition(ccp(winSize.width * 0.8, winSize.height * 0.3)); CCMenu* clearDialog = CCMenu::create(titleItem,retryItem,NULL); clearDialog->setPosition(CCPointZero); clearDialog->setTag(tagClearDialog); clearDialog->setOpacity(0); clearDialog->setEnabled(false); this->addChild(clearDialog); }
void MainGameScene::startGame() { //タッチを有効に setTouchEnabled(true); //リトライボタンを有効に CCMenu* retryButton = (CCMenu*)this->getChildByTag(tagRetryButton); if(retryButton){ retryButton->setEnabled(true); } //startInfoを消す CCMenu* startInfo = (CCMenu*)this->getChildByTag(tagStartInfo); if(startInfo){ this->removeChild(startInfo); } }
void UIScrollLayer::checkChildrenPos() { //CCArray* array = m_PageLayer->getChildren(); CCObject* obj; CCARRAY_FOREACH(m_PageLayer,obj) { CCLayer* layer = dynamic_cast<CCLayer*>(obj); if(layer) { CCArray* itemArray = layer->getChildren(); CCObject* itemObj; CCARRAY_FOREACH(itemArray,itemObj) { CCNode* iconButton = dynamic_cast<CCNode*>(itemObj); if(iconButton) { CCArray* menuArray = iconButton->getChildren(); CCObject* menuObj; CCARRAY_FOREACH(menuArray,menuObj) { CCMenu* menu = dynamic_cast<CCMenu*>(menuObj); if(menu) { CCArray* menuItemArray = menu->getChildren(); CCObject* menuItmeObj; bool claim = false; CCARRAY_FOREACH(menuItemArray,menuItmeObj) { CCMenuItem* item = dynamic_cast<CCMenuItem*>(menuItmeObj); if(item) { CCPoint pt = layer->convertToWorldSpace(menu->getPosition()); claim = touchIsInContent(pt); if(claim) { break; } } } menu->setEnabled(claim); } } }
bool GameMainLayer::init() { if (!CCLayer::init()) return false; CCSize size = CCDirector::sharedDirector()->getVisibleSize(); CCPoint originPoint = CCDirector::sharedDirector()->getVisibleOrigin(); map = new GameObjMap(); map->setAnchorPoint(ccp(0, 1)); map->setPosition(ccpSub(ccp(0, size.height), originPoint)); this->addChild(map, 0); hero = new GameObjHero(); hero->setScale(0.5f); hero->setPosition(ccpAdd(ccp(100, 160), originPoint)); this->addChild(hero, 1); gameMark = new GameMark(); this->addChild(gameMark, 4); //游戏结束 gameOver = CCSprite::create("gameover.png"); gameOver->setScale(0.5f); gameOver->setPosition(ccp(size.width/2, size.height/2 + 70)); gameOver->setVisible(false); this->addChild(gameOver, 5); //菜单项 CCMenuItemImage *pCloseItem = CCMenuItemImage::create("back.png", "back.png", this, menu_selector(GameMainLayer::menuBackCallback)); pCloseItem->setPosition(ccp(size.width/2, size.height/2 - 50)); pCloseItem->setScale(0.5f); CCMenu *pMenu = CCMenu::create(pCloseItem, NULL); pMenu->setPosition(CCPointZero); this->addChild(pMenu, 5, 25); pMenu->setVisible(false); pMenu->setEnabled(false); this->isOver = false; this->scheduleUpdate(); return true; }
//public void RPGStartSceneLayer::goToMapScene() { CCArray *loadTextures = CCArray::create(); loadTextures->addObject(CCString::create("map.png")); loadTextures->addObject(CCString::create("main.png")); loadTextures->addObject(CCString::create("joystick.png")); loadTextures->addObject(CCString::create("actor4_0.png")); loadTextures->addObject(CCString::create("actor111.png")); loadTextures->addObject(CCString::create("actor113.png")); loadTextures->addObject(CCString::create("actor114.png")); loadTextures->addObject(CCString::create("actor115.png")); loadTextures->addObject(CCString::create("actor117.png")); loadTextures->addObject(CCString::create("actor120.png")); CCMenu *mainMenu = (CCMenu*)this->getChildByTag(kRPGStartSceneLayerTagMainMenu); mainMenu->setEnabled(false); CCScene *s = RPGLoadingSceneLayer::scene(loadTextures, NULL, "single_map"); CCTransitionFade *t = CCTransitionFade::create(GAME_SCENE, s); CCDirector::sharedDirector()->replaceScene(t); }
void MainLayerZhuangBeiBaseBody::disableAllTouchBegin() { mTableView->setTouchEnabled(false); int cellNum = numberOfCellsInTableView(mTableView); for (int i=0; i<cellNum; i++) { CCTableViewCell* cell = mTableView->cellAtIndex(i); if (cell) { CCNode* bg = cell->getChildByTag(TAG_EquipBaseBody_TABLE_ITEM); if (bg) { CCMenu* menu = (CCMenu*)bg->getChildByTag(TAG_BaseBody_MENU); if (menu) { menu->setEnabled(false); } } } } mOffset = mTableView->getContentOffset(); }
void MainGameScene::endAnimation() { CCMenu* retryButton = (CCMenu*)this->getChildByTag(tagRetryButton); if(retryButton){ //retryButton->setOpacity(0); retryButton->setEnabled(false); } int moveIndex[25] = {1,2,3,4,5,10,15,20,25,24,23,22,21,16,11,6,7,8,9,14,19,18,17,12,13}; for(int i = 1; i <= COL_NUM * ROW_NUM; i++){ CCRotateBy* rotate = CCRotateBy::create(1.5, 360); Arrow* arrowObj = (Arrow *)this->getChildByTag(moveIndex[i-1]); CCDelayTime* delay = CCDelayTime::create(0.04 * i); CCSequence* seq; if(i == COL_NUM * ROW_NUM){ CCCallFunc* funcShowClearDialog = CCCallFunc::create(this, callfunc_selector(MainGameScene::showClearDialog)); seq = CCSequence::create(delay,rotate, funcShowClearDialog, NULL); }else{ seq = CCSequence::create(delay,rotate,NULL); } arrowObj->getArrowSprite()->runAction(seq); } CCSize winSize = CCDirector::sharedDirector()->getWinSize(); CCSprite* pC = CCSprite::create("clear_C.png"); pC->setPosition(ccp(winSize.width * 0.1, winSize.height * 0.6)); pC->setScale(0.0); pC->setZOrder(Z_ORDER_CLEAR_DIALOG); pC->runAction(CCSequence::create(CCDelayTime::create(0.1),Animation::clearCharaAction(),NULL)); this->addChild(pC); CCSprite* pL = CCSprite::create("clear_L.png"); pL->setPosition(ccp(winSize.width * 0.3, winSize.height * 0.6)); pL->setScale(0.0); pL->setZOrder(Z_ORDER_CLEAR_DIALOG); pL->runAction(CCSequence::create(CCDelayTime::create(0.3),Animation::clearCharaAction(),NULL)); this->addChild(pL); CCSprite* pE = CCSprite::create("clear_E.png"); pE->setPosition(ccp(winSize.width * 0.5, winSize.height * 0.6)); pE->setScale(0.0); pE->setZOrder(Z_ORDER_CLEAR_DIALOG); pE->runAction(CCSequence::create(CCDelayTime::create(0.5),Animation::clearCharaAction(),NULL)); this->addChild(pE); CCSprite* pA = CCSprite::create("clear_A.png"); pA->setPosition(ccp(winSize.width * 0.7, winSize.height * 0.6)); pA->setScale(0.0); pA->setZOrder(Z_ORDER_CLEAR_DIALOG); pA->runAction(CCSequence::create(CCDelayTime::create(0.7),Animation::clearCharaAction(),NULL)); this->addChild(pA); CCSprite* pR = CCSprite::create("clear_R.png"); pR->setPosition(ccp(winSize.width * 0.9, winSize.height * 0.6)); pR->setScale(0.0); pR->setZOrder(Z_ORDER_CLEAR_DIALOG); pR->runAction(CCSequence::create(CCDelayTime::create(0.9),Animation::clearCharaAction(),NULL)); this->addChild(pR); }
void LevelSelectScene::menuStartCallback(CCObject *pSender) { CCMenu* levelSelectMenu = (CCMenu*)this->getChildByTag(tagLevelSelectMenuDialog); if(levelSelectMenu){ levelSelectMenu->setOpacity(128); levelSelectMenu->setEnabled(false); } CCMenuItemImage* targetLevelImage = (CCMenuItemImage*)pSender; m_level = targetLevelImage->getTag(); CCSize winSize = CCDirector::sharedDirector()->getWinSize(); CCMenuItemImage* startMenuBG = CCMenuItemImage::create("logo_Info2.png","logo_Info2.png"); startMenuBG->setScale(0.7); startMenuBG->setPosition(ccp(winSize.width * 0.5, winSize.height * 0.5)); startMenuBG->setEnabled(false); CCString* levelStr = CCString::createWithFormat("Lv:%d",m_level); CCSize pStartBGSize = startMenuBG->getContentSize(); CCLabelTTF* levelLabel; levelLabel = CCLabelTTF::create(levelStr->getCString(), "Copperplate", 60.0); levelLabel->setColor(ccc3(0, 0, 0)); levelLabel->setPosition(ccp(pStartBGSize.width * 0.5 ,pStartBGSize.height * 0.75)); startMenuBG->addChild(levelLabel); //ハイスコアを表示 CCString* bestStr = CCString::createWithFormat("MIN:%d BEST:%d",min_score[m_level-1],best_score[m_level-1]); CCLabelTTF* bestLabel; bestLabel = CCLabelTTF::create(bestStr->getCString(), "Copperplate", 60.0); bestLabel->setColor(ccc3(0, 0, 0)); bestLabel->setPosition(ccp(pStartBGSize.width * 0.5 ,pStartBGSize.height * 0.5)); startMenuBG->addChild(bestLabel); CCMenuItemImage* titleItem = CCMenuItemImage::create("button1.png","button1.png" ,this, menu_selector(LevelSelectScene::startGame)); titleItem->setPosition(ccp(winSize.width * 0.3, winSize.height * 0.42)); CCLabelTTF* titleLabel; titleLabel = CCLabelTTF::create("START", "Arial", 30.0); CCSize pTitleItemSize = titleItem->getContentSize(); titleLabel->setPosition(ccp(pTitleItemSize.width / 2 ,pTitleItemSize.height / 2)); titleItem->addChild(titleLabel); titleItem->setScale(0.8); CCMenuItemImage* returnGameItem = CCMenuItemImage::create("button2.png","button2.png" ,this, menu_selector(LevelSelectScene::hiddenStartMenu)); returnGameItem->setPosition(ccp(winSize.width * 0.7, winSize.height * 0.42)); CCLabelTTF* returnGameLabel; returnGameLabel = CCLabelTTF::create("CANCEL", "Arial", 30.0); CCSize pReturnGameSize = returnGameItem->getContentSize(); returnGameLabel->setPosition(ccp(pReturnGameSize.width / 2 ,pReturnGameSize.height / 2)); returnGameItem->addChild(returnGameLabel); returnGameItem->setScale(0.8); CCMenu* resumeDialog = CCMenu::create(startMenuBG, titleItem, returnGameItem, NULL); resumeDialog->setPosition(CCPointZero); resumeDialog->setTag(tagStartMenuDialog); resumeDialog->setScale(winSize.width/640); this->addChild(resumeDialog); }
void RPGMapSceneLayer::playerMoveEnd() { CCTMXTiledMap *bgMap = (CCTMXTiledMap*)this->getChildByTag(kRPGMapSceneLayerTagBgMap); RPGMapRoleSprite *player = (RPGMapRoleSprite*)bgMap->getChildByTag(kRPGMapSceneLayerTagPlayer); player->stopMove(); player->stopActionByTag(kRPGMapSceneLayerActTagPlayerMove); this->m_playerMoveAct = NULL; //地图切换点的判断 CCTMXObjectGroup *transitionsObjects = bgMap->objectGroupNamed("transitions"); for (int i = 0; i < transitionsObjects->getObjects()->count(); i++) { CCDictionary *transitionsObject = (CCDictionary*)transitionsObjects->getObjects()->objectAtIndex(i); const CCString *x = transitionsObject->valueForKey("x"); const CCString *y = transitionsObject->valueForKey("y"); const CCString *width = transitionsObject->valueForKey("width"); const CCString *height = transitionsObject->valueForKey("height"); const CCString *mapId = transitionsObject->valueForKey("map_id"); const CCString *playerToX = transitionsObject->valueForKey("player_to_x"); const CCString *playerToY = transitionsObject->valueForKey("player_to_y"); const CCString *playerDirection = transitionsObject->valueForKey("player_direction"); CCRect transitionsRect = CCRectMake(stringToNumber<float>(x->getCString()), stringToNumber<float>(y->getCString()), stringToNumber<float>(width->getCString()), stringToNumber<float>(height->getCString())); if(transitionsRect.containsPoint(player->getPosition())) { // CCLog("切换场景%s", mapId->getCString()); //数据库部分,更新进度记录 //修正偏差位置,因为无法得知下一个地图的大小,所以目前只能在tmx上面定死 float toX = stringToNumber<float>(playerToX->getCString()) + 0.5; float toY = stringToNumber<float>(playerToY->getCString()) + 0.5; //保存数据 RPGSaveData *saveDataObj = RPGSaveData::create(); saveDataObj->m_mapId = stringToNumber<int>(mapId->getCString()); saveDataObj->m_playerToX = toX; saveDataObj->m_playerToY = toY; saveDataObj->m_playerDirection = playerDirection->getCString(); saveDataObj->m_gold = this->m_mapData.gold; saveDataObj->m_windowStyle = CCUserDefault::sharedUserDefault()->getStringForKey(GAME_STYLE); saveData(&this->m_db, saveDataObj); CCDirector::sharedDirector()->getTouchDispatcher()->removeDelegate(this); this->unscheduleUpdate(); CCScene *s = RPGMapSceneLayer::scene(0.0); CCTransitionFade *t = CCTransitionFade::create(GAME_SCENE, s); CCDirector::sharedDirector()->replaceScene(t); return; } } //遇敌处理 // this->m_hasEnemy = true; //test if(this->m_hasEnemy) { float val = CCRANDOM_0_1(); val = CCRANDOM_0_1(); if(val >= 0.0 && val <= GAME_MAP_ENCOUNTER) { // CCLog("遇敌!"); CCDirector::sharedDirector()->getTouchDispatcher()->removeDelegate(this); this->unscheduleUpdate(); CCTMXTiledMap *bgMap = (CCTMXTiledMap*)this->getChildByTag(kRPGMapSceneLayerTagBgMap); CCArray *loadTextures = CCArray::create(); loadTextures->addObject(CCString::create("monsters.png")); loadTextures->addObject(CCString::create("battle_bg.png")); CCArray *releaseTextures = CCArray::create(); releaseTextures->addObject(CCString::create("map.png")); releaseTextures->addObject(CCString::create("joystick.png")); releaseTextures->addObject(CCString::create("actor4_0.png")); releaseTextures->addObject(CCString::create("actor111.png")); releaseTextures->addObject(CCString::create("actor113.png")); releaseTextures->addObject(CCString::create("actor114.png")); releaseTextures->addObject(CCString::create("actor115.png")); releaseTextures->addObject(CCString::create("actor117.png")); releaseTextures->addObject(CCString::create("actor120.png")); CCMenu *mainMenu = (CCMenu*)bgMap->getChildByTag(kRPGMapSceneLayerTagMainMenu); mainMenu->setEnabled(false); SimpleAudioEngine::sharedEngine()->playEffect("audio_battle_start.wav"); // CCLog("%i", this->m_saveData.mapId); RPGMapRoleSprite *player = (RPGMapRoleSprite*)bgMap->getChildByTag(kRPGMapSceneLayerTagPlayer); CCUserDefault::sharedUserDefault()->setIntegerForKey("map_id", this->m_mapData.mapId); CCUserDefault::sharedUserDefault()->setFloatForKey("player_to_x", player->getPosition().x / GAME_TMX_ROLE_WIDTH); CCUserDefault::sharedUserDefault()->setFloatForKey("player_to_y", player->getPosition().y / GAME_TMX_ROLE_HEIGHT); CCUserDefault::sharedUserDefault()->setIntegerForKey("gold", this->m_mapData.gold); switch (player->m_direction) { case kRPGMapRoleSpriteDirectionUp: CCUserDefault::sharedUserDefault()->setStringForKey("player_direction", "up"); break; case kRPGMapRoleSpriteDirectionDown: CCUserDefault::sharedUserDefault()->setStringForKey("player_direction", "down"); break; case kRPGMapRoleSpriteDirectionLeft: CCUserDefault::sharedUserDefault()->setStringForKey("player_direction", "left"); break; case kRPGMapRoleSpriteDirectionRight: CCUserDefault::sharedUserDefault()->setStringForKey("player_direction", "right"); break; default: break; } CCScene *s = RPGLoadingSceneLayer::scene(loadTextures, releaseTextures, "single_battle"); CCTransitionFade *t = CCTransitionFade::create(GAME_SCENE, s); CCDirector::sharedDirector()->replaceScene(t); } } }
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; } }
void MainGameScene::makeResumeDaialog() { CCSize winSize = CCDirector::sharedDirector()->getWinSize(); //CCSpriteで作ると、タッチ判定無効とかめんどくさいからBGもMenuItemで作る CCMenuItemImage* resumeBG = CCMenuItemImage::create("logo_Info2.png","logo_Info2.png"); resumeBG->setScale(0.7); resumeBG->setPosition(ccp(winSize.width * 0.5, winSize.height * 0.5)); resumeBG->setEnabled(false); CCSize pResumeBGSize = resumeBG->getContentSize(); CCLabelTTF* resumeLabel; resumeLabel = CCLabelTTF::create(NKLocalizedString::LocalizedString("resume", "RESUME"), "Copperplate", 60.0); resumeLabel->setColor(ccc3(0, 0, 0)); resumeLabel->setPosition(ccp(pResumeBGSize.width * 0.5 ,pResumeBGSize.height * 0.7)); resumeBG->addChild(resumeLabel); CCMenuItemImage* titleItem = CCMenuItemImage::create("button1.png","button1.png" ,this, menu_selector(MainGameScene::tapTitleButton)); titleItem->setPosition(ccp(winSize.width * 0.3, winSize.height * 0.47)); CCLabelTTF* titleLabel; titleLabel = CCLabelTTF::create("TITLE", "Arial", 30.0); CCSize pTitleItemSize = titleItem->getContentSize(); titleLabel->setPosition(ccp(pTitleItemSize.width / 2 ,pTitleItemSize.height / 2)); titleItem->addChild(titleLabel); titleItem->setScale(0.8); CCMenuItemImage* returnGameItem = CCMenuItemImage::create("button2.png","button2.png" ,this, menu_selector(MainGameScene::returnMainGame)); returnGameItem->setPosition(ccp(winSize.width * 0.7, winSize.height * 0.47)); CCLabelTTF* returnGameLabel; returnGameLabel = CCLabelTTF::create("CANCEL", "Arial", 30.0); CCSize pReturnGameSize = returnGameItem->getContentSize(); returnGameLabel->setPosition(ccp(pReturnGameSize.width / 2 ,pReturnGameSize.height / 2)); returnGameItem->addChild(returnGameLabel); returnGameItem->setScale(0.8); CCMenuItemImage* retryGameItem = CCMenuItemImage::create("button3.png","button3.png" ,this, menu_selector(MainGameScene::doRetry)); retryGameItem->setPosition(ccp(winSize.width * 0.5, winSize.height * 0.39)); CCLabelTTF* retryGameLabel; retryGameLabel = CCLabelTTF::create("RETRY", "Arial", 30.0); CCSize pRetryGameSize = retryGameItem->getContentSize(); retryGameLabel->setPosition(ccp(pRetryGameSize.width / 2 ,pRetryGameSize.height / 2)); retryGameItem->addChild(retryGameLabel); retryGameItem->setScale(0.8); CCMenu* resumeDialog = CCMenu::create(resumeBG, titleItem, returnGameItem,retryGameItem,NULL); resumeDialog->setPosition(CCPointZero); resumeDialog->setTag(tagResumeDialog); resumeDialog->setOpacity(0); resumeDialog->setZOrder(Z_ORDER_RESUME_DIALOG); resumeDialog->setEnabled(false); this->addChild(resumeDialog); }