void BuildingBase::addMagicBuild(int _tyep) { if (m_magicBuild == NULL) { m_magicBuild = new vector<magicBuild*>; } CentralScene *pCentralScene = SceneManage::GetSceneManageHendle()->m_pCentralScene; if (SceneManage::GetSceneManageHendle()->m_pCentralScene->m_pCentralUILayer->updateGold(-1)) { CentralData::BuildableMagic* temp = pCentralScene->m_pCentralData->getBuildableMagic(_tyep); const BaseSpellData* baseSpellData; baseSpellData = GameData::GetDataFromBaseSpellData(temp->type * 100 + temp->leve); int s_num = 0; bool isHave = false; int num = (int)m_magicBuild->size(); for (int i = 0; i <num; i++) { magicBuild* soldiers = m_magicBuild->at(i); if (soldiers->tyep == _tyep) { soldiers->num += 1; s_num = soldiers->num; isHave = true; } } if (!isHave) { magicBuild *soldiers = new magicBuild(); memset( soldiers,0,sizeof(magicBuild) ); soldiers->tyep = _tyep; soldiers->num = 1; soldiers->MAXTime = baseSpellData->TrainingTime; soldiers->time = 0; s_num = soldiers->num; m_magicBuild->push_back(soldiers); } magicTyep = _tyep; isCancelMagic = 0; pCentralScene->m_pCentralLayer->buildingAccount(this,OperateType_MadeMagic); if (pCentralScene->m_pCentralInfoUILayer != NULL) { if (pCentralScene->m_pCentralInfoUILayer->arrIcon != NULL) { CCSprite* icon = (CCSprite*)pCentralScene->m_pCentralInfoUILayer->arrIcon->objectAtIndex(_tyep-1); CCLabelTTF *timeLabel = (CCLabelTTF*)icon->getChildByTag(1); timeLabel->setString(CommonResource::getStringFromInt(s_num).c_str()); } } } }
CTableSprite CStar97Game::CreateTableSprite() { CTableSprite tableSprite; CCSize szBKSize; if (m_pResManager->GenerateNodeByCfgID(eSpriteType_Cfg, Star97_Room_Table, tableSprite.m_pTableBK)) { szBKSize = tableSprite.m_pTableBK->getContentSize(); tableSprite.m_pTableBK->setAnchorPoint(ccp(0.5f, 0.5f)); tableSprite.m_pTableBK->setScale(1.4f); } if (m_pResManager->GenerateNodeByCfgID(eSpriteType_Cfg, Star97_Room_Table_P, tableSprite.m_pTableP)) { szBKSize = tableSprite.m_pTableP->getContentSize(); tableSprite.m_pTableP->setAnchorPoint(ccp(0.0f, 0.0f)); tableSprite.m_pTableP->setPosition(CCPoint(0,0)); tableSprite.m_pTableP->setZOrder(tableSprite.m_pTableBK->getZOrder()+1); tableSprite.m_pTableBK->addChild(tableSprite.m_pTableP); } //桌子编号 if (m_pResManager->GenerateNodeByCfgID(eSpriteType_Base, Star97_Room_Table_Num_Font, tableSprite.m_pTableNum)) { szBKSize = tableSprite.m_pTableBK->getContentSize(); tableSprite.m_pTableNum->setAnchorPoint(ccp(0.5, 0.5)); tableSprite.m_pTableNum->setPosition(ccp(120.f,240.f)); //tableSprite.m_pTableNum->setScale(0.3f); if (NULL != tableSprite.m_pTableBK) { tableSprite.m_pTableBK->addChild(tableSprite.m_pTableNum); } } //游戏桌子编号 if (m_pResManager->GenerateNodeByCfgID(eSpriteType_Base, Star97_Room_Table_Num_Font, tableSprite.m_pTableNumP)) { tableSprite.m_pTableNumP->setAnchorPoint(ccp(0.5, 0.5)); tableSprite.m_pTableNumP->setPosition(ccp(120.f,240.f)); //tableSprite.m_pTableNumP->setScale(0.3f); if (NULL != tableSprite.m_pTableP) { tableSprite.m_pTableP->addChild(tableSprite.m_pTableNumP); } } //座位 for (int n = 0; n < 1; n++) { CSeatSprite seat; CCLabelTTF *titleButton = CCLabelTTF::create("", "Arial", 30); if (NULL == titleButton) { ERROR_CHECK; break; } titleButton->setColor(ccc3(159, 168, 176)); CCScale9Sprite *backgroundButton = NULL; if (!m_pResManager->GenerateNodeByCfgID(eSpriteType_Cfg, Star97_Room_Sit, backgroundButton)) { ERROR_CHECK; break; } CCControlButton* pButton = CMoveableButton::create(titleButton, backgroundButton); if (NULL == pButton) { ERROR_CHECK; break; } CCScale9Sprite *backgroundHighlightedButton = NULL; if (m_pResManager->GenerateNodeByCfgID(eSpriteType_Cfg, Star97_Room_Sit, backgroundHighlightedButton)) { pButton->setBackgroundSpriteForState(backgroundHighlightedButton, CCControlStateHighlighted); } CCScale9Sprite *backgroundDisibleButton = NULL; if (m_pResManager->GenerateNodeByCfgID(eSpriteType_Cfg, Star97_Room_Sit_D, backgroundDisibleButton)) { pButton->setBackgroundSpriteForState(backgroundDisibleButton, CCControlStateDisabled); } pButton->setPosition(CCPoint(134.0f,105.0f)); pButton->setAdjustBackgroundImage(false); //pButton->setZoomOnTouchDown(false); pButton->setTag(n); if (tableSprite.m_pTableP) { pButton->setZOrder(tableSprite.m_pTableP->getZOrder()+4); } tableSprite.m_pTableBK->addChild(pButton); seat.m_pSeat = pButton; //更新名称 CCLabelTTF* pUserName = NULL; if (m_pResManager->GenerateNodeByCfgID(eSpriteType_Cfg, Star97_Font_Room_Sit_Name, pUserName)) { } if (pUserName && tableSprite.m_pTableBK) { szBKSize = tableSprite.m_pTableBK->getContentSize(); pUserName->setString(""); pUserName->setPosition(ccp(szBKSize.width*0.5,0)); pUserName->setHorizontalAlignment(kCCTextAlignmentCenter); pUserName->setVerticalAlignment(kCCVerticalTextAlignmentCenter); tableSprite.m_pTableBK->addChild(pUserName); seat.m_pNameLabel = pUserName; } tableSprite.m_vSeatSprites.push_back(seat); } return tableSprite; }
void BuildingBase::ImmediatelyComplete() { CentralScene *pCentralScene = SceneManage::GetSceneManageHendle()->m_pCentralScene; switch (m_uTypeID) { case ARMY_BARRACK: { if (m_peopleSoldiers != NULL) { isSafety = false; if ((int)m_peopleSoldiers->size() > 0) { pCentralScene->m_pCentralLayer->isUPSoldiers = false; pCentralScene->m_pCentralLayer->uploadRecruiting(); pCentralScene->m_pCentralLayer->buildingAccelerated(AccelerateType_MadeSoldiersAccelerated); for( int i = 0; i < (int)m_peopleSoldiers->size(); i++ ) { const BasePeopleData* pdata = GameData::GetDataFromBasePeopleData(m_peopleSoldiers->at(i)->tyep*100000+1); pCentralScene->m_pCentralData->m_Central_UserData->allYouPeopleNum += pdata->HousingSpace*m_peopleSoldiers->at(i)->num; for (int j = 0; j < m_peopleSoldiers->at(i)->num; j++) { //建兵 Unit* u = pCentralScene->m_pCentralLayer->AddPeople(m_peopleSoldiers->at(i)->tyep * 100000 +1, this->getPosition(),NULL); u->unit_ai_cmd_ = UNIT_AI_PATROL; for (int k=0; k<pCentralScene->m_pCentralData->m_BuildableSoldiers->size(); k++) { CentralData::BuildableSoldiers* s = pCentralScene->m_pCentralData->m_BuildableSoldiers->at(k); if (s->type == m_peopleSoldiers->at(i)->tyep) { s->num++; break; } } } } if (pCentralScene->m_pCentralInfoUILayer != NULL) { if (pCentralScene->m_pCentralInfoUILayer->m_type == ARMY_BARRACK) { if (pCentralScene->m_pCentralInfoUILayer->arrIcon != NULL) { for (int i = 0; i < pCentralScene->m_pCentralInfoUILayer->arrIcon->count(); i++) { CCSprite* icon = (CCSprite*)pCentralScene->m_pCentralInfoUILayer->arrIcon->objectAtIndex(i); CCLabelTTF *timeLabel = (CCLabelTTF*)icon->getChildByTag(1); if (timeLabel != NULL) { timeLabel->setString(""); } } for (int i = 0; i < pCentralScene->m_pCentralInfoUILayer->arrAIcon->count(); i++) { CCSprite* iconA = (CCSprite*)pCentralScene->m_pCentralInfoUILayer->arrAIcon->objectAtIndex(i); iconA->removeFromParentAndCleanup(false); } pCentralScene->m_pCentralInfoUILayer->arrAIcon->removeAllObjects(); pCentralScene->m_pCentralInfoUILayer->btn_SpeedUp->setVisible(false); pCentralScene->m_pCentralInfoUILayer->m_AllTimeLabel->setString(""); pCentralScene->m_pCentralInfoUILayer->m_AllPeopleLabel->setString(""); pCentralScene->m_pCentralInfoUILayer->s_bgl1->setVisible(false); pCentralScene->m_pCentralInfoUILayer->s_bgl3->setVisible(false); } } } allProductionTime = 0; for( int i = 0; i < (int)m_peopleSoldiers->size(); i++ ) { delete m_peopleSoldiers->at(i); } m_peopleSoldiers->clear(); } isSafety = true; } } break; case ARMY_LABORATORY: { //升级成功 if (tipNode != NULL) { //回收动画 tipNode->removeFromParentAndCleanup(false); tipNode = NULL; } pCentralScene->m_pCentralLayer->Accelerated_upid = UpLeveTyep; upLeveComplete(UpLeveTyep); UpLeveTyep = 0; //上传服务器 if (isMroS) { pCentralScene->m_pCentralLayer->buildingAccelerated(AccelerateType_UpMagicAccelerated); } else { pCentralScene->m_pCentralLayer->buildingAccelerated(AccelerateType_UpMadeSoldiersAccelerated); } } break; case ARMY_SPELLFORGE: { if (m_magicBuild != NULL) { for( int i = 0; i < (int)m_magicBuild->size(); i++ ) { } } } break; default: break; } }
BaseSprite* MainLayerZhuangBeiBaseBody::getItemContentByIndex(unsigned int index) { BaseSprite* bg = BaseSprite::create("mianban_zhuangbei_xiangxi.png"); CCString tempStr; CCPoint picPos = ccp(75.0f, bg->getContentSize().height/2); { ImageData diWenData = ImageManager::getManager()->getImageData_DiWen_List( mEquipmentVec[index]->getEquipColor(), false, mEquipmentVec[index]->isPartOfSuit(), mEquipmentVec[index]->haveZhuanke()); BaseSprite* diWen = BaseSprite::create(diWenData.getCurrentImageFile()); diWen->setScale(diWenData.scale); diWen->setPosition(picPos); bg->addChild(diWen,0,TAG_BaseBody_TABLE_ITEM_DiWen); { BaseSprite *sprite = ImageManager::getManager()->getSpriteOfZhuangbei(mEquipmentVec[index],true,true); //sprite->setScale(data.scale); sprite->setScale(0.43f); sprite->setPosition(picPos); bg->addChild(sprite,0,TAG_BaseBody_TABLE_ITEM_Image); } //封印 if (mEquipmentVec[index]->isInFengYin()) { BaseSprite *fyImg = BaseSprite::create("shenbing_fengyin_suo.png"); bg->addChild(fyImg, 0, TAG_BaseBody_TABLE_FengYin_Img); fyImg->setPosition(diWen->getPosition()); fyImg->setScale(diWen->getContentSize().width*diWen->getScale() / fyImg->getContentSize().width); } } // 添加图片识别区 { ImageData selecedData = ImageManager::getManager()->getImageData_DiWen_Selected( mEquipmentVec[index]->getEquipColor(), false,//mEquipmentVec[index]->isShenBing(), mEquipmentVec[index]->isPartOfSuit()); BaseSprite* menuItemSel = BaseSprite::create(selecedData.getCurrentImageFile()); menuItemSel->setScale(selecedData.scale); CCSprite* menuRect = CCSprite::createWithTexture(menuItemSel->getTexture()); menuRect->setScale(0.0f); FXScrollMenu *menu = FXScrollMenu::create( mTableView->getParent()->convertToWorldSpace(mTableView->getPosition()), mTableView->getViewSize()); bg->addChild(menu, 0, TAG_BaseBody_MENU); menu->setPosition(ccp(0,0)); CCMenuItemSprite* t = CCMenuItemSprite::create(menuRect,menuItemSel,this,SEL_MenuHandler(&MainLayerZhuangBeiBaseBody::itemImageClicked)); menu->addChild(t, 0, index); t->setPosition(picPos); } float left_x_start = 160 - 4; //名称 { CCLabelTTF* label; char str[64]; if (mEquipmentVec[index]->getEquipData().qianghua_data.qianghua_count != 0) { sprintf(str, "%s", mEquipmentVec[index]->getName().c_str()); } else { sprintf(str, "%s", mEquipmentVec[index]->getName().c_str()); } label = LF::lable(bg,str,ccp(left_x_start,190),24,fontStr_kaiti); label->setTag(TAG_BaseBody_LABLE_NAME); ccColor3B color = ImageManager::getManager()->getShowColor(mEquipmentVec[index]->getEquipColor(),false,mEquipmentVec[index]->isPartOfSuit()); label->setColor(color); } //类型 { std::string typeStr = CS::getZhuangbeiTypeName(mEquipmentVec[index]->getType(), mEquipmentVec[index]->getEquipColor()); CCLabelTTF* label; label = LF::lable(bg,typeStr,ccp(left_x_start,165),18,fontStr_kaiti); label->setTag(TAG_BaseBody_LABLE_TYPE); label->setColor(fonColor_CiYao); } //白字 { CCLabelTTF* label_baizhi = NULL; bool hasBaiZhi = false; { float baizi = 0; switch(mEquipmentVec[index]->getType()) { case ZhuangbeiType_DanshouJian: case ZhuangbeiType_ShuangshouBishou: case ZhuangbeiType_ShuangshouFu: case ZhuangbeiType_DanshouFazhang: case ZhuangbeiType_ShuangshouFazhang: case ZhuangbeiType_Gong: hasBaiZhi = true; baizi = mEquipmentVec[index]->getGongjiLiAfterQianghua(false); break; case ZhuangbeiType_Dunpai: case ZhuangbeiType_KuijiaZhong: case ZhuangbeiType_KuijiaQin: hasBaiZhi = true; baizi = mEquipmentVec[index]->getHuJiaZhiAfterQianghua(); break; default: break; } if (hasBaiZhi) { char str[64]; sprintf(str, "%.1f", baizi); label_baizhi = LF::lable(bg,str,ccp(left_x_start,126),60,fontStr_BookAntiqua); label_baizhi->setTag(TAG_BaseBody_LABLE_BAIZI); } else { label_baizhi = LF::lable(bg,"",ccp(left_x_start,126),60,fontStr_BookAntiqua); label_baizhi->setTag(TAG_BaseBody_LABLE_BAIZI); } } //junshang CCLabelTTF* label_junshang = LF::lable(bg,LFStrings::getValue("junshang"),ccp(0,0),20,fontStr_kaiti); label_junshang->setAnchorPoint(ccp(0, 0.5)); label_junshang->setPosition( ccp(label_baizhi->getPositionX()+label_baizhi->getContentSize().width+10, 116)); label_junshang->setTag(TAG_BaseBody_LABLE_JUNSHANG_TXT); if(hasBaiZhi) { label_junshang->setVisible(true); if(mEquipmentVec[index]->getEquipType() == EquipType_FangJu) label_junshang->setString(LFStrings::getValue("huJia").c_str()); } else { label_junshang->setVisible(false); } } //伤害详细 if (mEquipmentVec[index]->getEquipType() == EquipType_WuQi) { CCLabelTTF* label; char str[64]; sprintf(str, "%u-%u ", mEquipmentVec[index]->getEquipData().gongji_min , mEquipmentVec[index]->getEquipData().gongji_max); label = LF::lable(bg,str,ccp(left_x_start,87),20,fontStr_BookAntiqua); label->setTag(TAG_BaseBody_LABLE_SHANGHAIXIANGXI_NUM); label->setColor(fonColor_CiYao); CCLabelTTF* label2; label2 = LF::lable(bg,LFStrings::getValue("dianShangHai") ,ccp(label->getPosition().x + label->getContentSize().width, label->getPositionY()),20,fontStr_kaiti); label2->setTag(TAG_BaseBody_LABLE_SHANGHAIXIANGXI_TXT); label2->setColor(fonColor_CiYao); } else { CCLabelTTF* label; label = LF::lable(bg,"",ccp(left_x_start,87),20,fontStr_kaiti); label->setTag(TAG_BaseBody_LABLE_SHANGHAIXIANGXI_NUM); CCLabelTTF* label2; label2 = LF::lable(bg,"" ,ccp(label->getPosition().x + label->getContentSize().width, label->getPositionY()),20,fontStr_kaiti); label2->setTag(TAG_BaseBody_LABLE_SHANGHAIXIANGXI_TXT); } //等级 { CCLabelTTF* label; char str[64]; sprintf(str, "%s %u ", LFStrings::getValue("dengji").c_str(), mEquipmentVec[index]->getEquipData().zhuangbei_level); label = LF::lable(bg,str,ccp(left_x_start,28),20,fontStr_kaiti); label->setColor(fonColor_FaGuang); label->setTag(TAG_BaseBody_LABLE_Level); } //人物 { CCLabelTTF* label; int actorId = mEquipmentVec[index]->getActorId(); if (actorId != INVALID_ID) { BaseActor* actor = MyselfManager::getManager()->getMyTeamActor(actorId); CCAssert(actor!=NULL,""); BaseActorProperty prop = actor->getCurrentProperty(); label = LF::lable(bg,LF::getString("zhuangBeiYu")+prop.nameInChinese,ccp(0, 0),20,fontStr_kaiti); } else { label = LF::lable(bg,LF::getString("meiYouZhuangBei"),ccp(0, 0),20,fontStr_kaiti); } label->setColor(fonColor_FaGuang); label->setAnchorPoint(ccp(1, 0.5)); label->setPosition(ccp( 590, 200)); label->setTag(TAG_BaseBody_LABLE_OWNTO); if (actorId == INVALID_ID && mEquipmentVec[index]->getEquipData().profession_id != 0) { CCString temp; temp.initWithFormat("%s(%s)", LFStrings::getValue("ZhiYeXianZhi").c_str(), BaseActorPropertyParser::getParser()->getExtraProerty((Profession)mEquipmentVec[index]->getEquipData().profession_id).nameInChinese.c_str()); label->setString(temp.getCString()); label->setColor(fonColor_JingGao); } } //魔法属性 { int start_x = 400 + 38; Equipment* equip = mEquipmentVec[index]; std::vector<std::string> vec = equip->getAllMofaShuxing(false); //大于5个 第五个就是 ...... for(int i=0; i<vec.size(); ++i) { std::string txt = vec[i]; BaseSprite* biaoji = BaseSprite::create("zhuangbei_xiangxi_biaoji.png"); bg->addChild(biaoji, 0, TAG_BIAOJI+i); biaoji->setPosition(ccp(start_x, 170-i*28)); //biaoji->setOpacity(80); CCLabelTTF* label; label = LF::lable(bg,txt,ccp(0,0),20,fontStr_kaiti); label->setColor(ImageManager::getManager()->getShowColor(ZhuangbeiColour_Fumo, false, false)); label->setAnchorPoint(ccp(0, 0.5)); label->setPosition(ccp(start_x+15, 170-i*28)); label->setTag(i); if(vec.size()>6) { CCLog("Warrior:%s ---> equipment property > 6, current is [%d]", __FUNCTION__, vec.size()); // break; } } //洗练 string xxx; CCSprite *diwen = (CCSprite*)bg->getChildByTag(TAG_BaseBody_TABLE_ITEM_DiWen); if (equip->canPurify(xxx,1) && diwen) { ZhuangbeiOptionLevel *layer = ZhuangbeiOptionLevel::createWithEquipment(equip); bg->addChild(layer,20); //layer->setScale(1/diwen->getScale()); CCPoint pos = diwen->getPosition(); pos.x -= diwen->getContentSize().width * diwen->getScaleX() / 2; pos.y -= diwen->getContentSize().height * diwen->getScaleY() / 2; int width = pos.x + layer->getContentSize().width / 2 + 12; int height = pos.y + layer->getContentSize().height / 2 + 4; layer->setPosition(ccp(width,height)); } } bg->setPosition(ccp(bg->getContentSize().width/2,bg->getContentSize().height/2)); return bg; }
CurrentLanguageTest::CurrentLanguageTest() { CCLabelTTF* label = CCLabelTTF::create("Current language Test", "Arial", 28); addChild(label, 0); label->setPosition( ccp(VisibleRect::center().x, VisibleRect::top().y-50) ); CCLabelTTF *labelLanguage = CCLabelTTF::create("", "Arial", 20); labelLanguage->setPosition(VisibleRect::center()); ccLanguageType currentLanguageType = CCApplication::sharedApplication()->getCurrentLanguage(); switch (currentLanguageType) { case kLanguageEnglish: labelLanguage->setString("current language is English"); break; case kLanguageChinese: labelLanguage->setString("current language is Chinese"); break; case kLanguageFrench: labelLanguage->setString("current language is French"); break; case kLanguageGerman: labelLanguage->setString("current language is German"); break; case kLanguageItalian: labelLanguage->setString("current language is Italian"); break; case kLanguageRussian: labelLanguage->setString("current language is Russian"); break; case kLanguageSpanish: labelLanguage->setString("current language is Spanish"); break; case kLanguageKorean: labelLanguage->setString("current language is Korean"); break; case kLanguageJapanese: labelLanguage->setString("current language is Japanese"); break; case kLanguageHungarian: labelLanguage->setString("current language is Hungarian"); break; case kLanguagePortuguese: labelLanguage->setString("current language is Portuguese"); break; case kLanguageArabic: labelLanguage->setString("current language is Arabic"); break; case kLanguageDutch: labelLanguage->setString("current language is Dutch"); break; default: break; } addChild(labelLanguage); }
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 SpriteWordAndImage::AddLabel() { for (int i=0; i<15; i++) { m_Imgs[i].clear(); } CCLabelTTF * tl = CCLabelTTF::create("", m_fontName, m_fontSize); //生成代替图片的空格 string imgWord = " "; tl->setString(imgWord.c_str()); float imgWidth = tl->getContentSize().width; while (imgWidth < image_width) { imgWord += " "; tl->setString(imgWord.c_str()); imgWidth = tl->getContentSize().width; } string oriStr = m_label; string outStr = ""; string lineStr = ""; BYTE wordBegin = 0; BYTE imgIndex = 0; BYTE lineIndex = 1; float width = 0; float height = 0; float lineHeight = line_height; bool isImage = false; int count = CommonFunction::calcCharCount(oriStr.c_str()); for (int i=0; i<count; i++) { string word = CommonFunction::subString(oriStr, i,1); if (word.c_str()[0] == '[' && i+2<count) { string nimg; int end = i+1; while (CommonFunction::subString(oriStr, end,1).c_str()[0] != ']' && end < count) { end++; } if (CommonFunction::subString(oriStr, end,1).c_str()[0] == ']') { m_Imgs[imgIndex].nUsed = true; m_Imgs[imgIndex].nImg = CommonFunction::subString(oriStr,i+1,end-i-1); word = imgWord; i = end; isImage = true; } } lineStr += word; tl->setString(lineStr.c_str()); if (colorType == CT_Black) { tl->setColor(CC_Black); } width = tl->getContentSize().width; if (width > m_width) { //判断是否要换行 CCLabelTTF * l = CCLabelTTF::create(outStr.c_str(), m_fontName, m_fontSize); l->setAnchorPoint(ccp(0,0.5)); if (colorType == CT_Black) { l->setColor(CC_Black); } l->setPosition(ccp(0, height - lineHeight*0.5)); addChild(l); height -= lineHeight; lineHeight = line_height; outStr = word; lineStr = word; lineIndex++; } else { outStr += word; } wordBegin = i; if (isImage) { //计算图片位置 图片索引累加 lineHeight = image_height>lineHeight?image_height:lineHeight; m_Imgs[imgIndex].nWidth= width > m_width?imgWidth*0.5:width-imgWidth*0.5; m_Imgs[imgIndex].nHeight = height - lineHeight*0.5; imgIndex++; } isImage = false; } CCLabelTTF * l = CCLabelTTF::create(outStr.c_str(), m_fontName, m_fontSize); l->setAnchorPoint(ccp(0,0.5)); if (colorType == CT_Black) { l->setColor(CC_Black); } l->setPosition(ccp(0, height- lineHeight*0.5)); countHeight = (height-lineHeight)*-1; //算总高度 addChild(l); AddImages(); tl->release(); }
void GameScene::step(float dt) { particles_counter += dt; if (particles_counter > 0.15) { particles->setEmissionRate(0); } // Return if game suspended if(gameSuspended) return; // Get the jumper sprite CCSprite *jumper = (CCSprite*)getChildByTag(kjumper); // Update the player x position based on velocity and delta time jumper_pos.x += jumper_vel.x * dt; jumper->setRotation(jumper_vel.x); // Flip the player based on it's x velocity and current looking direction if(jumper_vel.x < -30.0f && jumperLookingRight) { jumperLookingRight = false; jumper->setScaleX(-1.0f); } else if (jumper_vel.x > 30.0f && !jumperLookingRight) { jumperLookingRight = true; jumper->setScaleX(1.0f); } // Calculate the max and min x values for the jumper // based on the screen and jumper widths CCSize jumper_size = jumper->getContentSize(); // float max_x = (float)CCDirector::sharedDirector()->getWinSize().width - jumper_size.width/2; // float min_x = jumper_size.width/2; // Limit the jumper position based on max and min values allowed // if(jumper_pos.x>max_x) jumper_pos.x = max_x; // if(jumper_pos.x<min_x) jumper_pos.x = min_x; float max_x = (float)CCDirector::sharedDirector()->getWinSize().width + jumper_size.width/2.0; float min_x = -jumper_size.width/2.0; // Limit the character position based on max and min values allowed if(jumper_pos.x>max_x) jumper_pos.x = jumper_size.width/2.0; if(jumper_pos.x<min_x) jumper_pos.x = (float)CCDirector::sharedDirector()->getWinSize().width - jumper_size.width/2.0; // Update the jumper velocity based on acceleration and time // if (isPowerPicked) // { // jumper_vel.y += (jumper_acc.y * dt)*3; // } // else { jumper_vel.y += jumper_acc.y * dt; } // Update the jumper y positin based on velocity and time jumper_pos.y += jumper_vel.y * dt; //////////////////////////////////////////////////////////////////////////// // Handle the bonus scoring float delta = jumper_pos.y - ((float)CCDirector::sharedDirector()->getWinSize().height / 2); // If bonus is visible then see if the jumper is within range to get the bonus // If the jumper has stopped moving then make it jump from the platform it is on int t; if(jumper_vel.y < 0) { t = kPlatformsStartTag; // Search through all the platforms and compare the jumpers position with the platfor position for(t; t < kPlatformsStartTag + kNumPlatforms; t++) { CCSprite *platform = (CCSprite*)getChildByTag(t); CCSize platform_size = platform->getContentSize(); CCPoint platform_pos = platform->getPosition(); max_x = platform_pos.x - platform_size.width/2 - 2; min_x = platform_pos.x + platform_size.width/2 + 2; float min_y = platform_pos.y + (platform_size.height+jumper_size.height)/2 - kPlatformTopPadding; if(jumper_pos.x > (max_x) && jumper_pos.x < (min_x) && jumper_pos.y > platform_pos.y && jumper_pos.y < min_y) { if (platform->getTag() == kKillerPlatformTag) { coin50Platform = 12; coin100Platform = 15; coinJumpPlatform = 25; SharedData::getSharedInstance()->gameover_Text = "Gameover"; CCScene *pScene = GameOverScene::scene(); CCDirector::sharedDirector()->pushScene(pScene); this->unscheduleAllSelectors(); } else { jump(); break; // Can only jump from one platform at a time to break out of the loop } } } // If the jumper has fallen below the screen then game over if(jumper_pos.y < - jumper_size.height/2) { coin50Platform = 12; coin100Platform = 15; coinJumpPlatform = 25; SharedData::getSharedInstance()->gameover_Text = "Gameover"; CCScene *pScene = GameOverScene::scene(); CCDirector::sharedDirector()->pushScene(pScene); this->unscheduleAllSelectors(); // resetjumper(); } } else if ( jumper_pos.y > ((float)CCDirector::sharedDirector()->getWinSize().height / 2)) { // If jumper position is greater than the middle of the screen then move the platforms // the difference between the jumper y position and middle point of the screen resetTree(); // Set the jumper y position to the middle of the screen jumper_pos.y = (float)CCDirector::sharedDirector()->getWinSize().height / 2; // Move the current platform y by the delta amount currentPlatformY -= delta; // Move the clouds vertically and reset if necessary t = kCloudsStartTag; for (t; t < kCloudsStartTag + kNumClouds; t++) { CCSprite *cloud = (CCSprite*) getChildByTag(t); CCPoint pos = cloud->getPosition(); // Calculate new position for cloud pos.y -= delta * cloud->getScaleY() * 0.8f; // If the cloud is off the screen then need to reset this cloud else set its new position if (pos.y < -cloud->getContentSize().height/2) { currentCloudTag = t; resetCloud(); } else { // Update the new y position for the cloud. cloud->setPosition(pos); } } // Move the platforms vertically and reset if necessary t = kPlatformsStartTag; int t_coin = kBonusStartTag; for (t; t < kPlatformsStartTag + kNumPlatforms; t++) { CCSprite *platform = (CCSprite*)getChildByTag(t); CCPoint pos = platform->getPosition(); // Calculate new position for platform pos = ccp(pos.x, pos.y - delta); // If the platform is off the screen then reset the platform else set its new position if(pos.y < - platform->getContentSize().height/2) { currentPlatformTag = t; resetPlatform(); } else { platform->setPosition(pos); } } //move particle system if (particles) { CCPoint pos = particles->getPosition(); pos.y -= delta; particles->setPosition(pos); } // If the bonus is visible then adjust it's y position // Update score based on how much the jumper has moved score += (int)delta*0.3 ; // if (score >= target_Score) // { // SharedData::getSharedInstance()->gameover_Text = "Level Cleared"; // CCScene *pScene = GameOverScene::scene(); // CCDirector::sharedDirector()->pushScene(pScene); // this->unscheduleAllSelectors(); // } // Display the new score value char scoreStr[10] = {0}; sprintf(scoreStr, "%d", score); CCLabelTTF* scoreLabel = (CCLabelTTF*) getChildByTag(kScoreLabel); scoreLabel->setString(scoreStr); int t_coins = kBonusStartTag; for (t_coins; t_coins < (kNumCoines + kBonusStartTag); t_coins++) { //////////////////////////////////////////////////////////////////////////// // Handle the coin scoring CCSprite *coin = (CCSprite*)getChildByTag(t_coins); // If coin is visible then see if the character is within range to get the coin if(coin->isVisible() ) { CCPoint coin_pos = coin->getPosition(); float range = 30.0f; CCPoint pos = coin->getPosition(); { // Calculate new position of coin pos.y -= delta; // If the coin is off the screen then reset the coin else set its new position if(pos.y < -coin->getContentSize().height/2 ) { // resetCoin(); } else { coin->setPosition(pos); } } } } t_coins = kBonusStartTag+30; for (t_coins; t_coins < (kNumCoines + kBonusStartTag+30); t_coins++) { //////////////////////////////////////////////////////////////////////////// // Handle the coin scoring CCSprite *coin = (CCSprite*)getChildByTag(t_coins); // If coin is visible then see if the character is within range to get the coin if(coin->isVisible() ) { CCPoint coin_pos = coin->getPosition(); float range = 30.0f; CCPoint pos = coin->getPosition(); { // Calculate new position of coin pos.y -= delta; // If the coin is off the screen then reset the coin else set its new position if(pos.y < -coin->getContentSize().height/2 ) { // resetCoin(); } else { coin->setPosition(pos); } } } } t_coins = kBonusStartTag+60; for (t_coins; t_coins < (kNumCoines + kBonusStartTag+60); t_coins++) { //////////////////////////////////////////////////////////////////////////// // Handle the coin scoring CCSprite *coin = (CCSprite*)getChildByTag(t_coins); // If coin is visible then see if the character is within range to get the coin if(coin->isVisible() ) { CCPoint coin_pos = coin->getPosition(); float range = 30.0f; CCPoint pos = coin->getPosition(); { // Calculate new position of coin pos.y -= delta; // If the coin is off the screen then reset the coin else set its new position if(pos.y < -coin->getContentSize().height/2 ) { // resetCoin(); } else { coin->setPosition(pos); } } } } } int t_coins = kBonusStartTag; for (t_coins; t_coins < (kNumCoines + kBonusStartTag); t_coins++) { //////////////////////////////////////////////////////////////////////////// // Handle the coin scoring CCSprite *coin = (CCSprite*)getChildByTag(t_coins); // If coin is visible then see if the character is within range to get the coin if(coin->isVisible() ) { CCPoint coin_pos = coin->getPosition(); float range = 30.0f; // If the player is within range of the coin value then award the prize if(jumper_pos.x > coin_pos.x - range && jumper_pos.x < coin_pos.x + range && jumper_pos.y > coin_pos.y - range && jumper_pos.y < coin_pos.y + range ) { // Build the score string to display char scoreStr[10] = {0}; score += 50; sprintf(scoreStr, "%d", score); CCLabelTTF* scoreLabel = (CCLabelTTF*) getChildByTag(kScoreLabel); scoreLabel->setString(scoreStr); coin->setVisible(false); } } } t_coins = kBonusStartTag+30; for (t_coins; t_coins < (kNumCoines + kBonusStartTag+30); t_coins++) { //////////////////////////////////////////////////////////////////////////// // Handle the coin scoring CCSprite *coin = (CCSprite*)getChildByTag(t_coins); // If coin is visible then see if the character is within range to get the coin if(coin->isVisible() ) { CCPoint coin_pos = coin->getPosition(); float range = 30.0f; // If the player is within range of the coin value then award the prize if(jumper_pos.x > coin_pos.x - range && jumper_pos.x < coin_pos.x + range && jumper_pos.y > coin_pos.y - range && jumper_pos.y < coin_pos.y + range ) { // Build the score string to display char scoreStr[10] = {0}; score += 100; sprintf(scoreStr, "%d", score); CCLabelTTF* scoreLabel = (CCLabelTTF*) getChildByTag(kScoreLabel); scoreLabel->setString(scoreStr); coin->setVisible(false); } } } t_coins = kBonusStartTag+60; for (t_coins; t_coins < (kNumCoines + kBonusStartTag+60); t_coins++) { //////////////////////////////////////////////////////////////////////////// // Handle the coin scoring CCSprite *coin = (CCSprite*)getChildByTag(t_coins); // If coin is visible then see if the character is within range to get the coin if(coin->isVisible() ) { CCPoint coin_pos = coin->getPosition(); float range = 30.0f; // If the player is within range of the coin value then award the prize if(jumper_pos.x > coin_pos.x - range && jumper_pos.x < coin_pos.x + range && jumper_pos.y > coin_pos.y - range && jumper_pos.y < coin_pos.y + range ) { // Build the score string to display this->powerPicked(); coin->setVisible(false); } } } for (int i = kTree1Tag; i <= kTree3Tag; i++) { float delta = jumper_pos.y - ((float)CCDirector::sharedDirector()->getWinSize().height / 2); CCSprite * tree = (CCSprite *)this->getChildByTag(i); if ( jumper_pos.y > ((float)CCDirector::sharedDirector()->getWinSize().height / 2)) { tree->setPosition(ccp(tree->getPosition().x,tree->getPosition().y-delta)); } if (tree->getPosition().y <= -0.5*CCDirector::sharedDirector()->getWinSize().height ) { float posY; if (i == kTree1Tag) { CCSprite * temp = (CCSprite *)this->getChildByTag(kTree3Tag); posY = temp->getPosition().y + temp->getContentSize().height*0.99; tree->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width*0.5, posY)); } else if (i == kTree2Tag) { CCSprite * temp = (CCSprite *)this->getChildByTag(kTree1Tag); posY = temp->getPosition().y + temp->getContentSize().height*0.99; tree->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width*0.5, posY)); } else if (i == kTree3Tag) { CCSprite * temp = (CCSprite *)this->getChildByTag(kTree2Tag); posY = temp->getPosition().y + temp->getContentSize().height*0.99; tree->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width*0.5, posY)); } } } for (int i = kTree11Tag; i <= kTree33Tag; i++) { float delta = jumper_pos.y - ((float)CCDirector::sharedDirector()->getWinSize().height / 2); CCSprite * tree = (CCSprite *)this->getChildByTag(i); if ( jumper_pos.y > ((float)CCDirector::sharedDirector()->getWinSize().height / 2)) { tree->setPosition(ccp(tree->getPosition().x,tree->getPosition().y-delta*0.1)); } if (tree->getPosition().y <= -0.5*CCDirector::sharedDirector()->getWinSize().height ) { float posY; if (i == kTree11Tag) { CCSprite * temp = (CCSprite *)this->getChildByTag(kTree33Tag); posY = temp->getPosition().y + temp->getContentSize().height*0.99; tree->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width*0.5, posY)); } else if (i == kTree22Tag) { CCSprite * temp = (CCSprite *)this->getChildByTag(kTree11Tag); posY = temp->getPosition().y + temp->getContentSize().height*0.99; tree->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width*0.5, posY)); } else if (i == kTree33Tag) { CCSprite * temp = (CCSprite *)this->getChildByTag(kTree22Tag); posY = temp->getPosition().y + temp->getContentSize().height*0.99; tree->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width*0.5, posY)); } } } // Set the jumpers position jumper->setPosition(jumper_pos); }
void IOSStoreLayer::initUI() { //初始化背景 m_pBg = CCSprite::create(ResManager::getManager()->getFilePathByLanguageType(g_storelayerPath+"main_shangdian_bg.png").c_str()); this->addChild(m_pBg, 1, bg_tag); m_pBg->setPosition(ccp(this->getContentSize().width/2, this->getContentSize().height/2)); m_pKaibaoxiangNode = CCScale9Sprite::create(ResManager::getManager()->getSharedFilePath(g_seasonlayerPath+"nodebg.png").c_str()); m_pKaibaoxiangNode->ignoreAnchorPointForPosition(false); m_pKaibaoxiangNode->setAnchorPoint(ccp(0.5f, 0.5f)); m_pKaibaoxiangNode->setContentSize(m_pBg->getContentSize()); m_pKaibaoxiangNode->setPosition(ccp(m_pBg->getContentSize().width/2, m_pBg->getContentSize().height/2)); m_pBuyStarNode = CCScale9Sprite::create(ResManager::getManager()->getSharedFilePath(g_seasonlayerPath+"nodebg.png").c_str()); m_pBuyStarNode->ignoreAnchorPointForPosition(false); m_pBuyStarNode->setAnchorPoint(ccp(0.5f, 0.5f)); m_pBuyStarNode->setPosition(ccp(m_pBg->getContentSize().width/2, m_pBg->getContentSize().height/2)); m_pBuyStarNode->setContentSize(m_pBg->getContentSize()); m_pBg->addChild(m_pKaibaoxiangNode, 3, kaibaoxiang_node_tag); m_pBg->addChild(m_pBuyStarNode, 3, buystar_node_tag); m_pBgMenu = CCMenu::create(); m_pBgMenu->setPosition(CCPointZero); m_pBg->addChild(m_pBgMenu, 2); //左上角提示背景 CCSprite* pTip = CCSprite::create(ResManager::getManager()->getSharedFilePath(g_storelayerPath+"main_shangdian_tishi.png").c_str()); m_pBg->addChild(pTip, 0, tip_bg_tag); pTip->setPosition(ccp(pTip->getContentSize().width/2 - 25, m_pBg->getContentSize().height-pTip->getContentSize().height/2 - 30)); //左上角提示字符串 CCLabelTTF* pTipStr = CCLabelTTF::create(LFStrings::getValue("ShangdiangTipStr_lefttop_juqing").c_str(), fontStr_katong, 24, CCSizeMake(210, 80), kCCTextAlignmentLeft); m_pBg->addChild(pTipStr, 1, lefttop_tip_str_tag); pTipStr->setPosition(ccp(pTip->getPositionX() + 20, pTip->getPositionY() - 25)); pTipStr->setString(""); //中间提示字符 CCLabelTTF* pTipCenterStr = CCLabelTTF::create(LFStrings::getValue("ShangdiangTipStr_center_01").c_str(), fontStr_katong, 24); m_pBg->addChild(pTipCenterStr, 1, center_tip_str_tag); pTipCenterStr->setColor(ccc3(150, 60, 20)); pTipCenterStr->setPosition(ccp(m_pBg->getContentSize().width/2, m_pBg->getContentSize().height - 160)); pTipCenterStr->setString(""); //右边星星数 CCLabelAtlas* lable = CCLabelAtlas::create( "0123456789", ResManager::getManager()->getSharedFilePath(g_seasonlayerPath+"season_star_amount.png").c_str(), 30, 47,//24 '0'); m_pBg->addChild(lable, 1, star_count_str_tag); lable->setScale(0.6f); char charStarCount[10] = {}; int iStarCount = GameInforEditer::getGameInfor()->getTotalFreeScore(); sprintf(charStarCount, "%d", iStarCount); lable->setString(charStarCount); lable->setPosition(ccp(m_pBg->getContentSize().width - 120, m_pBg->getContentSize().height - 175)); //右边字符 CCSprite* pShuzi = CCSprite::create(ResManager::getManager()->getFilePathByLanguageType(g_seasonlayerPath+"season_amount.png").c_str()); m_pBg->addChild(pShuzi, 1); pShuzi->setScale(0.6f); pShuzi->setPosition(ccp(lable->getPositionX() - 50, pTipCenterStr->getPositionY())); //右边星星图标 CCSprite* pXingxing = CCSprite::create(ResManager::getManager()->getSharedFilePath(g_xiaogk+"YX_start.png").c_str()); m_pBg->addChild(pXingxing, 1); pXingxing->setPosition(ccp(pShuzi->getPositionX() - 50, pShuzi->getPositionY())); }
void HelloWorld::ccTouchEnded(CCTouch *touch, CCEvent *event) { CCLabelTTF *label = (CCLabelTTF *)this->getChildByTag(999); label->setString(""); }
CCTableViewCell* MailListScene::tableCellAtIndex(CCTableView *table, unsigned int idx) { CCString *string = (CCString *)mArrayList->objectAtIndex(idx); CCSize size = this->tableCellSizeForIndex(table, idx); CCTableViewCell *cell = table->dequeueCell(); if (!cell) { cell = new CCTableViewCell(); cell->autorelease(); CCSprite *sState = CCSprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("mail_state_read.png")); sState->setAnchorPoint(CCPointMake(0, 0.5)); sState->setPosition(ccp(10,size.height * 0.5)); sState->setTag(120); cell->addChild(sState); CCLabelTTF *lblName = CCLabelTTF::create(string->getCString(), "Arial", 14.0); lblName->setPosition(ccp(65,size.height * 0.5)); lblName->setColor(ccc3(255, 255, 204)); //lblName->enableStroke(ccc3(51, 0, 0), 0.6); lblName->setTag(121); lblName->setHorizontalAlignment(kCCTextAlignmentLeft); lblName->setString(string->getCString()); cell->addChild(lblName); CCLabelTTF *lblSubject = CCLabelTTF::create("100", "Arial", 14.0); lblSubject->setPosition(ccp(130,size.height * 0.5)); lblSubject->setColor(ccc3(255, 255, 204)); //lblSubject->enableStroke(ccc3(51, 0, 0), 0.6); lblSubject->setTag(122); lblSubject->setString(string->getCString()); cell->addChild(lblSubject); CCScale9Sprite *sline = CCScale9Sprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("mail_line.png")); sline->setPreferredSize(CCSizeMake(310, 1)); sline->setPosition(ccp(0,size.height-2)); sline->setAnchorPoint(CCPointZero); cell->addChild(sline); CCMenu *menuCheck = this->generateCheckBox(); cell->addChild(menuCheck); CCMenuItemToggle *toggle= (CCMenuItemToggle *)menuCheck->getChildByTag(1); toggle->setUserData(&vUserData[idx]); if (vUserData[idx] == 1) { toggle->setSelectedIndex(1); } else { toggle->setSelectedIndex(0); } menuCheck->setTag(123); menuCheck->setAnchorPoint(CCPointMake(0, 0.5)); menuCheck->setPosition(CCPointMake(280, size.height * 0.5)); } else { CCLabelTTF *lblName = (CCLabelTTF*)cell->getChildByTag(121); lblName->setString(string->getCString()); CCLabelTTF *lblSubject = (CCLabelTTF*)cell->getChildByTag(122); lblSubject->setString(string->getCString()); CCMenu *menuCheck = (CCMenu *)cell->getChildByTag(123); CCMenuItemToggle *toggle= (CCMenuItemToggle *)menuCheck->getChildByTag(1); toggle->setUserData(&vUserData[idx]); if (vUserData[idx] == 1) { toggle->setSelectedIndex(1); } else { toggle->setSelectedIndex(0); } } return cell; }
void StoryWorld::avgGame(void) { CCLabelTTF* myDialog = (CCLabelTTF *)getChildByTag(100); CCLabelTTF* myName = (CCLabelTTF *)getChildByTag(101); CCSpriteBatchNode *spriteBatch = (CCSpriteBatchNode *)getChildByTag(102); CCSprite *myLeftSprite = (CCSprite *)spriteBatch->getChildByTag(1); CCSprite *myRightSprite = (CCSprite *)spriteBatch->getChildByTag(2); strcpy(dialog, reader.GetNextDialog().c_str()); char theName[10][11]={"","穆婧:", "子轩:", "少杰:", "建国", "路人A:", "路人B:", "路人C:", "老爷爷:", "江姐:"}; myName->setString(theName[dialog[0]-48]); characterPasterSwitchCase(dialog[0]); switch (dialog[2]) { case '1': { setTouchEnabled(false); CCSprite *back = CCSprite::create(LANDSCAPE_IMG_PATH); back->setPosition(ccp(CCDirector::sharedDirector()->getVisibleSize().width/2, CCDirector::sharedDirector()->getVisibleSize().height/2)); back->setOpacity(150); back->setTag(3); addChild(back, 3); switch (current) { case '3': { CCLabelTTF *Label1 = CCLabelTTF::create("Yes", "Heiti SC", 40); CCLabelTTF *Label2 = CCLabelTTF::create("No", "Heiti SC", 40); CCMenuItemLabel *firstChoice = CCMenuItemLabel::create(Label1, this, menu_selector(StoryWorld::leafletChoiceHandler)); CCMenuItemLabel *secondChoice = CCMenuItemLabel::create(Label2, this, menu_selector(StoryWorld::leafletChoiceHandler)); firstChoice->setTag(fChoice); secondChoice->setTag(sChoice); firstChoice->setPosition(ccp(CCDirector::sharedDirector()->getVisibleSize().width/2, CCDirector::sharedDirector()->getVisibleSize().height/5 * 4.1)); secondChoice->setPosition(ccp(CCDirector::sharedDirector()->getVisibleSize().width/2, CCDirector::sharedDirector()->getVisibleSize().height/5 * 2.9)); CCMenu *menu = CCMenu::create(firstChoice, secondChoice, NULL); menu->setPosition(CCPointZero); menu->setTag(2); addChild(menu, 3); return; } break; case '9': { CCLabelTTF *Label1 = CCLabelTTF::create("子轩", "Heiti SC", 40); CCLabelTTF *Label2 = CCLabelTTF::create("少杰", "Heiti SC", 40); CCLabelTTF *Label3 = CCLabelTTF::create("建国", "Heiti SC", 40); CCMenuItemLabel *firstChoice = CCMenuItemLabel::create(Label1, this, menu_selector(StoryWorld::theFinalChoiceHandler)); CCMenuItemLabel *secondChoice = CCMenuItemLabel::create(Label2, this, menu_selector(StoryWorld::theFinalChoiceHandler)); CCMenuItemLabel *thirdChoice = CCMenuItemLabel::create(Label3, this, menu_selector(StoryWorld::theFinalChoiceHandler)); firstChoice->setTag(fChoice); secondChoice->setTag(sChoice); thirdChoice->setTag(tChoice); firstChoice->setPosition(ccp(CCDirector::sharedDirector()->getVisibleSize().width/2, CCDirector::sharedDirector()->getVisibleSize().height/5 * 4.1)); secondChoice->setPosition(ccp(CCDirector::sharedDirector()->getVisibleSize().width/2, CCDirector::sharedDirector()->getVisibleSize().height/5 * 2.9)); thirdChoice->setPosition(ccp(CCDirector::sharedDirector()->getVisibleSize().width/2, CCDirector::sharedDirector()->getVisibleSize().height/5 * 1.8)); CCMenu *menu = CCMenu::create(firstChoice, secondChoice, thirdChoice, NULL); menu->setPosition(CCPointZero); menu->setTag(2); addChild(menu, 3); return; } break; default: break; } } break; case '2': { } break; case '3': { if (myLeftSprite->getOpacity() == 0) myLeftSprite->setOpacity(255); else myLeftSprite->runAction(CCFadeOut::create(1)); } break; case '4': { if (myRightSprite->getOpacity() == 0) myRightSprite->setOpacity(255); else myRightSprite->runAction(CCFadeOut::create(1)); } break; case '5': { if (myRightSprite->getOpacity()==0 && myLeftSprite->getOpacity()==0) { myLeftSprite->setOpacity(255); myRightSprite->setOpacity(255); } else if (myRightSprite->getOpacity()!=0 && myLeftSprite->getOpacity()!=0) { myLeftSprite->runAction(CCFadeOut::create(1)); myRightSprite->runAction(CCFadeOut::create(1)); } } break; default: break; } specialPartSwitchCase(dialog[3]); audioSwitchCase(dialog[4]); char all_bg[8][4] = {"010", "030", "204", "701", "717", "725", "732"}; char bg_num[4]="000"; int curLine = reader.getCurLine(); sprintf(bg_num, "%c%02d", current, curLine); if (curLine == 0) { CCSprite *Background = (CCSprite *)getChildByTag(108); char bg_name[30]=BGNAME_IMG_PATH; bg_name[BGNAME_PATH_LEN] = current; Background->setTexture(GET_TEXTURE(bg_name)); } else { for (int i =0; i<8; i++) { if (strcmp(all_bg[i], bg_num)==0) { CCSprite *Background = (CCSprite *)getChildByTag(108); char bg_name[30]=""; sprintf(bg_name, BGNAME_IMG_PATH, bg_num); Background->setTexture(GET_TEXTURE(bg_name)); } } } myDialog->setString(dialog+5); }
bool RoleLayer::init() { CCLayer::init(); //this->setContentSize(designResolutionSize); //CCSprite *role = CCSprite::createWithSpriteFrameName("Apple.png"); //role->setPosition(ccp(this->getContentSize().width/2,this->getContentSize().height/2)); //this->addChild(role); // test tile map //CCTMXTiledMap *tiledMap = CCTMXTiledMap::create("testmap.tmx"); //tiledMap->setAnchorPoint(ccp(.5,.5)); //tiledMap->setPosition(ccp(this->getContentSize().width/2,this->getContentSize().height/2)); //this->addChild(tiledMap); // kDebugLabel CCLabelTTF *pDebugLabel = CCLabelTTF::create("", "Arial", 40); pDebugLabel->setPosition(ccp(this->getContentSize().width/2,this->getContentSize().height/2)); pDebugLabel->setString("init"); this->addChild(pDebugLabel, 100, kDebugLabel); // control btn CCScale9Sprite * btnNormal = CCScale9Sprite::createWithSpriteFrameName("Acorn_Squash.png"); CCScale9Sprite* btnDown = CCScale9Sprite::createWithSpriteFrameName("Apple.png"); CCLabelTTF * ttf_down = CCLabelTTF::create("[Down]", "Arial", 60); CCControlButton * cb_down = CCControlButton::create(ttf_down, btnNormal); cb_down->setBackgroundSpriteForState(btnDown, CCControlStateSelected); cb_down->setPosition(ccp(600,60)); this->addChild(cb_down, 100, kDownControl); cb_down->addTargetWithActionForControlEvents(this, cccontrol_selector(RoleLayer::down_power_on), CCControlEventTouchDown); cb_down->addTargetWithActionForControlEvents(this, cccontrol_selector(RoleLayer::down_power_on), CCControlEventTouchDragEnter); cb_down->addTargetWithActionForControlEvents(this, cccontrol_selector(RoleLayer::down_power_off), CCControlEventTouchDragExit); cb_down->addTargetWithActionForControlEvents(this, cccontrol_selector(RoleLayer::down_power_on), CCControlEventTouchDragInside); cb_down->addTargetWithActionForControlEvents(this, cccontrol_selector(RoleLayer::down_power_off), CCControlEventTouchDragOutside); cb_down->addTargetWithActionForControlEvents(this, cccontrol_selector(RoleLayer::down_power_off), CCControlEventTouchUpInside); cb_down->addTargetWithActionForControlEvents(this, cccontrol_selector(RoleLayer::down_power_off), CCControlEventTouchUpOutside); cb_down->addTargetWithActionForControlEvents(this, cccontrol_selector(RoleLayer::down_power_off), CCControlEventTouchCancel); // control btn CCScale9Sprite * btnNormal2 = CCScale9Sprite::createWithSpriteFrameName("Acorn_Squash.png"); CCScale9Sprite* btnDown2 = CCScale9Sprite::createWithSpriteFrameName("Apple.png"); CCLabelTTF * ttf_left = CCLabelTTF::create("[left]", "Arial", 60); CCControlButton * cb_left = CCControlButton::create(ttf_left, btnNormal2); cb_left->setBackgroundSpriteForState(btnDown2, CCControlStateSelected); cb_left->setPosition(ccp(100,60)); this->addChild(cb_left, 100, kDownControl); cb_left->addTargetWithActionForControlEvents(this, cccontrol_selector(RoleLayer::left_power_on), CCControlEventTouchDown); cb_left->addTargetWithActionForControlEvents(this, cccontrol_selector(RoleLayer::left_power_on), CCControlEventTouchDragEnter); cb_left->addTargetWithActionForControlEvents(this, cccontrol_selector(RoleLayer::left_power_off), CCControlEventTouchDragExit); cb_left->addTargetWithActionForControlEvents(this, cccontrol_selector(RoleLayer::left_power_on), CCControlEventTouchDragInside); cb_left->addTargetWithActionForControlEvents(this, cccontrol_selector(RoleLayer::left_power_off), CCControlEventTouchDragOutside); cb_left->addTargetWithActionForControlEvents(this, cccontrol_selector(RoleLayer::left_power_off), CCControlEventTouchUpInside); cb_left->addTargetWithActionForControlEvents(this, cccontrol_selector(RoleLayer::left_power_off), CCControlEventTouchUpOutside); cb_left->addTargetWithActionForControlEvents(this, cccontrol_selector(RoleLayer::left_power_off), CCControlEventTouchCancel); // control btn CCScale9Sprite * btnNormal3 = CCScale9Sprite::createWithSpriteFrameName("Acorn_Squash.png"); CCScale9Sprite* btnDown3 = CCScale9Sprite::createWithSpriteFrameName("Apple.png"); CCLabelTTF * ttf_right = CCLabelTTF::create("[right]", "Arial", 60); CCControlButton * cb_right = CCControlButton::create(ttf_right, btnNormal3); cb_right->setBackgroundSpriteForState(btnDown3, CCControlStateSelected); cb_right->setPosition(ccp(1180,60)); this->addChild(cb_right, 100, kDownControl); cb_right->addTargetWithActionForControlEvents(this, cccontrol_selector(RoleLayer::right_power_on), CCControlEventTouchDown); cb_right->addTargetWithActionForControlEvents(this, cccontrol_selector(RoleLayer::right_power_on), CCControlEventTouchDragEnter); cb_right->addTargetWithActionForControlEvents(this, cccontrol_selector(RoleLayer::right_power_off), CCControlEventTouchDragExit); cb_right->addTargetWithActionForControlEvents(this, cccontrol_selector(RoleLayer::right_power_on), CCControlEventTouchDragInside); cb_right->addTargetWithActionForControlEvents(this, cccontrol_selector(RoleLayer::right_power_off), CCControlEventTouchDragOutside); cb_right->addTargetWithActionForControlEvents(this, cccontrol_selector(RoleLayer::right_power_off), CCControlEventTouchUpInside); cb_right->addTargetWithActionForControlEvents(this, cccontrol_selector(RoleLayer::right_power_off), CCControlEventTouchUpOutside); cb_right->addTargetWithActionForControlEvents(this, cccontrol_selector(RoleLayer::right_power_off), CCControlEventTouchCancel); // space ship CCSprite * ship = CCSprite::create("space_ship.png"); ship->setPosition(ccp(this->getContentSize().width/2,this->getContentSize().height/2)); this->addChild(ship, 50, kShip); // data init ai[0] = ai[1] = ai[2] = ccp(0,0); a = CCPointMake(0,0); v = CCPointMake(0,0); schedule(schedule_selector(RoleLayer::step)); return true; }
CCTableViewCell* S2TestMain::tableCellAtIndex(CCTableView *table, unsigned int idx) { int tableTag = table->getTag(); if (tableTag==11) {//PracticeList TableView CCString *strCell = CCString::create(aVectorCellSmallValue[idx]); CCTableViewCell *pCell = table->dequeueCell(); if (!pCell) { pCell = new CCTableViewCell(); pCell->autorelease(); CCSprite *pSprite = CCSprite::create("cellLine.png"); pSprite->setPosition(CCPointZero); pSprite->setAnchorPoint(CCPointZero); pCell->addChild(pSprite,1); { CCLabelTTF *pLabel = CCLabelTTF::create(strCell->getCString(), "Arial", s2FontSize3_macro, s2Size2_macro(aCell), kCCTextAlignmentLeft, kCCVerticalTextAlignmentCenter); pLabel->setPosition(ccp(s2Less3_macro,0)); pLabel->setAnchorPoint(CCPointZero); pLabel->setColor(ccc3(0,0,0)); pLabel->setTag(s2Tag1); pCell->addChild(pLabel,1); } } CCLabelTTF *pLabel = (CCLabelTTF*)pCell->getChildByTag(s2Tag1); pLabel->setString(strCell->getCString()); return pCell; }else if (tableTag==12){//TableView CCString *strCell = CCString::create(aVectorCellValue[idx]); CCTableViewCell *pCell = table->dequeueCell(); if (!pCell) { pCell = new CCTableViewCell(); pCell->autorelease(); CCSprite *pSprite = CCSprite::create("cellLine.png"); pSprite->setPosition(CCPointZero); pSprite->setAnchorPoint(CCPointZero); pCell->addChild(pSprite,1); { CCLabelTTF *pLabel = CCLabelTTF::create(strCell->getCString(), "Arial", s2FontSize3_macro, s2Size4_macro(aCell), kCCTextAlignmentLeft, kCCVerticalTextAlignmentCenter); pLabel->setPosition(ccp(s2Less3_macro,0)); pLabel->setAnchorPoint(CCPointZero); pLabel->setColor(ccc3(0,0,0)); pLabel->setTag(s2Tag1); pCell->addChild(pLabel,1); } { CCLabelTTF *pLabel = CCLabelTTF::create("Completed", "Arial",s2FontSize3_macro, s2Size5_macro(aItem), kCCTextAlignmentRight, kCCVerticalTextAlignmentCenter); pLabel->setPosition(s2PositionC7_macro(aItem)); pLabel->setAnchorPoint(CCPointZero); pLabel->setColor(ccc3(0,0,255)); pLabel->setTag(s2Tag1); pCell->addChild(pLabel,1); } } CCLabelTTF *pLabel = (CCLabelTTF*)pCell->getChildByTag(10); pLabel->setString(strCell->getCString()); return pCell; } return NULL; }
void PlayMenu::updateLifeCountLabel(){ CCLabelTTF *lifeCountLabel = (CCLabelTTF *) this->getChildByTag(KTAG_Life_Count); string TotalLifeCount = static_cast<ostringstream*>( &(ostringstream() << GAME_SHARED_HANDLER->getLives()) )->str(); TotalLifeCount="Life Count " + TotalLifeCount; lifeCountLabel->setString(TotalLifeCount.c_str()); }
void StoryWorld::avgGame(void) { CCLabelTTF* myDialog = (CCLabelTTF *)getChildByTag(100); CCLabelTTF* myName = (CCLabelTTF *)getChildByTag(101); CCSpriteBatchNode *spriteBatch = (CCSpriteBatchNode *)getChildByTag(102); CCSprite *myLeftSprite = (CCSprite *)spriteBatch->getChildByTag(1); CCSprite *myRightSprite = (CCSprite *)spriteBatch->getChildByTag(2); strcpy(dialog, reader.GetNextDialog().c_str()); char theName[10][11]={"","穆婧1:", "子轩:", "少杰:", "建国", "路人A:", "路人B:", "路人C:", "老爷爷:", "江姐:"}; myName->setString(theName[dialog[0]-48]); //任务立绘切换 switch (dialog[0]) { case '0': { //无人 char b[10]="me_ .png"; b[3] = dialog[1]+1; myLeftSprite->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(b)); } break; case '1': { //ME char b[10]="me_ .png"; b[3] = dialog[1]+1; myLeftSprite->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(b)); } break; case '2': { //子轩 char b[10]="zx_ .png"; b[3] = dialog[1]+1; myRightSprite->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(b)); } break; case '3': { //少杰 char b[10]="sj_ .png"; b[3] = dialog[1]; myRightSprite->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(b)); } break; case '4': { //建国 char b[10]="jg_ .png"; b[3] = dialog[1]; myRightSprite->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(b)); } break; case '5': { char b[10]="la_ .png"; b[3] = dialog[1]; myRightSprite->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(b)); } break; case '6': { char b[10]="lb_ .png"; b[3] = dialog[1]; myRightSprite->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(b)); } break; case '7': { char b[10]="lc_ .png"; b[3] = dialog[1]; myRightSprite->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(b)); } break; case '8': { char b[10]="yy_ .png"; b[3] = dialog[1]; myRightSprite->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(b)); } break; case '9': { char b[10]="jj_ .png"; b[3] = dialog[1]; myRightSprite->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(b)); } break; default: break; } switch (dialog[2]) { // 选择走向 case '1': { //开始选择走向 //停止触摸 setTouchEnabled(false); CCSprite *back = CCSprite::create(LANDSCAPE_IMG_PATH); back->setPosition(ccp(CCDirector::sharedDirector()->getVisibleSize().width/2, CCDirector::sharedDirector()->getVisibleSize().height/2)); back->setOpacity(150); back->setTag(3); addChild(back, 3); switch (current) { case '3': { CCLabelTTF *Label1 = CCLabelTTF::create("Yes", "Heiti SC", 40); CCLabelTTF *Label2 = CCLabelTTF::create("No", "Heiti SC", 40); CCMenuItemLabel *firstChoice = CCMenuItemLabel::create(Label1, this, menu_selector(StoryWorld::makeAChoice)); CCMenuItemLabel *secondChoice = CCMenuItemLabel::create(Label2, this, menu_selector(StoryWorld::makeAChoice)); firstChoice->setTag(fChoice); secondChoice->setTag(sChoice); firstChoice->setPosition(ccp(CCDirector::sharedDirector()->getVisibleSize().width/2, CCDirector::sharedDirector()->getVisibleSize().height/5 * 4.1)); secondChoice->setPosition(ccp(CCDirector::sharedDirector()->getVisibleSize().width/2, CCDirector::sharedDirector()->getVisibleSize().height/5 * 2.9)); CCMenu *menu = CCMenu::create(firstChoice, secondChoice, NULL); menu->setPosition(CCPointZero); menu->setTag(2); addChild(menu, 3); return; } break; case '9': { //创建CCMenu CCLabelTTF *Label1 = CCLabelTTF::create("子轩", "Heiti SC", 40); CCLabelTTF *Label2 = CCLabelTTF::create("少杰", "Heiti SC", 40); CCLabelTTF *Label3 = CCLabelTTF::create("建国", "Heiti SC", 40); CCMenuItemLabel *firstChoice = CCMenuItemLabel::create(Label1, this, menu_selector(StoryWorld::makeAChoice)); CCMenuItemLabel *secondChoice = CCMenuItemLabel::create(Label2, this, menu_selector(StoryWorld::makeAChoice)); CCMenuItemLabel *thirdChoice = CCMenuItemLabel::create(Label3, this, menu_selector(StoryWorld::makeAChoice)); firstChoice->setTag(fChoice); secondChoice->setTag(sChoice); thirdChoice->setTag(tChoice); firstChoice->setPosition(ccp(CCDirector::sharedDirector()->getVisibleSize().width/2, CCDirector::sharedDirector()->getVisibleSize().height/5 * 4.1)); secondChoice->setPosition(ccp(CCDirector::sharedDirector()->getVisibleSize().width/2, CCDirector::sharedDirector()->getVisibleSize().height/5 * 2.9)); thirdChoice->setPosition(ccp(CCDirector::sharedDirector()->getVisibleSize().width/2, CCDirector::sharedDirector()->getVisibleSize().height/5 * 1.8)); CCMenu *menu = CCMenu::create(firstChoice, secondChoice, thirdChoice, NULL); menu->setPosition(CCPointZero); menu->setTag(2); addChild(menu, 3); return; } break; default: break; } } break; case '2': { CCScene *combatScene = Combat::scene(); CCDirector::sharedDirector()->pushScene(combatScene); } break; case '3': { if (myLeftSprite->getOpacity() == 0) myLeftSprite->setOpacity(255); else myLeftSprite->runAction(CCFadeOut::create(1)); } break; case '4': { if (myRightSprite->getOpacity() == 0) myRightSprite->setOpacity(255); else myRightSprite->runAction(CCFadeOut::create(1)); } break; case '5': { if (myRightSprite->getOpacity()==0 && myLeftSprite->getOpacity()==0) { myLeftSprite->setOpacity(255); myRightSprite->setOpacity(255); } else if (myRightSprite->getOpacity()!=0 && myLeftSprite->getOpacity()!=0) { myLeftSprite->runAction(CCFadeOut::create(1)); myRightSprite->runAction(CCFadeOut::create(1)); } } break; default: break; } // 剧本切换及完结及特效 switch (dialog[3]) { case '1':{ // 保存进度 current+=1; CCEGLView::sharedOpenGLView()->setDesignResolutionSize(672, 448, kResolutionExactFit); CCDirector::sharedDirector()->popScene(); // TODO: POP OUT } break; case '2':{ // wanjie CCSprite* staff_bg = CCSprite::create(STAFFBG_IMG_PATH); staff_bg->setPosition(ccp(CCDirector::sharedDirector()->getVisibleSize().width/2 + CCDirector::sharedDirector()->getVisibleOrigin().x, CCDirector::sharedDirector()->getVisibleSize().height/2 + CCDirector::sharedDirector()->getVisibleOrigin().y)); addChild(staff_bg, 4); CCSprite* staff = CCSprite::create(STAFF_IMG_PATH ); staff->setPosition(ccp(CCDirector::sharedDirector()->getVisibleSize().width/2, -CCDirector::sharedDirector()->getVisibleSize().height/2)); addChild(staff, 5); CCActionInterval * moveTo = CCMoveTo::create(20,ccp(CCDirector::sharedDirector()->getVisibleSize().width/2, CCDirector::sharedDirector()->getVisibleSize().height*3/2)); CCFiniteTimeAction* sequneceAction = CCSequence::create( moveTo, CCCallFunc::create(this, callfunc_selector(StoryWorld::over)), NULL); staff->runAction(sequneceAction); } break; case '3':{ CCSprite *black = CCSprite::create(BLACK_IMG_PATH); black->setPosition(ccp(CCDirector::sharedDirector()->getVisibleSize().width/2, CCDirector::sharedDirector()->getVisibleSize().height/2)); black->setOpacity(0); addChild(black, 4); black->runAction(CCSequence::create(CCFadeIn::create(0.5), CCFadeOut::create(0.5), NULL)); } break; default: break; } //音效 switch (dialog[4]) { case '1': case '2': case '3': case '4': case '5': case '6':{ char musicName[7] = " .mp3"; musicName[0] = dialog[4]; if (CocosDenshion::SimpleAudioEngine::sharedEngine()->isBackgroundMusicPlaying()) { CocosDenshion::SimpleAudioEngine::sharedEngine()->stopBackgroundMusic(true); } CocosDenshion::SimpleAudioEngine::sharedEngine()->preloadBackgroundMusic(CCFileUtils::sharedFileUtils()->fullPathForFilename(musicName).c_str()); CocosDenshion::SimpleAudioEngine::sharedEngine()->playBackgroundMusic(CCFileUtils::sharedFileUtils()->fullPathForFilename(musicName).c_str(), true); } break; case '7': { CocosDenshion::SimpleAudioEngine::sharedEngine()->stopBackgroundMusic(true); } break; case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'G':{ char effectName[7] = " .wav"; effectName[0] = dialog[4]; CocosDenshion::SimpleAudioEngine::sharedEngine()->preloadEffect(CCFileUtils::sharedFileUtils()->fullPathForFilename(effectName).c_str()); CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect(CCFileUtils::sharedFileUtils()->fullPathForFilename(effectName).c_str()); } break; case 'E': case 'F': case 'H':{ char effectName[7] = " .mp3"; effectName[0] = dialog[4]; CocosDenshion::SimpleAudioEngine::sharedEngine()->preloadEffect(CCFileUtils::sharedFileUtils()->fullPathForFilename(effectName).c_str()); CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect(CCFileUtils::sharedFileUtils()->fullPathForFilename(effectName).c_str()); } break; default: break; } // 背景 char all_bg[8][4] = {"010", "030", "204", "701", "717", "725", "732"}; char bg_num[4]="000"; int curLine = reader.getCurLine(); sprintf(bg_num, "%c%02d", current, curLine); if (curLine == 0) { CCSprite *Background = (CCSprite *)getChildByTag(108); char bg_name[30]=BGNAME_IMG_PATH; bg_name[BGNAME_PATH_LEN] = current; Background->setTexture(CCTextureCache::sharedTextureCache()->addImage(bg_name)); } else { for (int i =0; i<8; i++) { if (strcmp(all_bg[i], bg_num)==0) { CCSprite *Background = (CCSprite *)getChildByTag(108); char bg_name[30]="img/story/bg_000.jpg"; sprintf(bg_name, "img/story/bg_%s.jpg", bg_num); Background->setTexture(CCTextureCache::sharedTextureCache()->addImage(bg_name)); } } } myDialog->setString(dialog+5); }