void LevelMap::adjustMap(bool isResetLevel) { int num = floor(offsetY/442); currentMap = -num; int offnum = num%3; float tmpoff = offsetY - num*442; mapLayer->setPosition(ccp(0, (offnum-1)*442 + tmpoff)); if(isResetLevel) { int offlevel = 1000 + currentMap*3 -3; for (int i = 0; i < 9 ; i++) { MapItem* tmpLevelItemData = NULL; tmpLevelItemData = CData::getCData()->getConfigOfMapLevel(offlevel + i); CCMenuItemSprite* tmp = (CCMenuItemSprite*)levelSpDic->objectForKey(i); tmp->removeChildByTag(9999); if (tmpLevelItemData!= NULL && tmpLevelItemData->bid < currentLevelId) { CCSize tmpsz = tmp->getContentSize(); CCSprite* ssp = CCSprite::create(); int num = data["citylist"][tmpLevelItemData->bid - 1000].asInt(); for (int k = 0; k<num; k++) { CCSprite * star = CCSprite::create("zjm_star.png"); star->setPosition(ccp(k*30, 0)); ssp->addChild(star); } ssp->setPosition(ccp(tmpsz.width/2-15*num+15, 0)); ssp->setTag(9999); tmp->addChild(ssp, 0); } if(tmpLevelItemData != NULL) { if(tmpLevelItemData->bid > currentLevelId) { tmp->setEnabled(false); } else { tmp->setEnabled(true); } tmp->setUserObject(tmpLevelItemData); } //for (int j = 1001; j<=1005; j++) //{ CCLabelTTF* tmpName = (CCLabelTTF*)(tmp->getChildByTag(1002)); if(tmpLevelItemData) { tmpName->setString(tmpLevelItemData->nickname.c_str()); } //} } } levelsMenu->setPosition(ccp(0, -442 + tmpoff)); }
void PrepareLayer::initPet(int leftOrRight) { ///**初始化已经出战的左边的宠物**/// int petId = -1; for (int i =0;i !=6; ++i ) { if (GameConfigData::initialGameData().getPetStateById(i) == "2") { if (GameConfigData::initialGameData().getPetPosById(i) == leftOrRight) { petId = i; } } } CCMenuItemSprite *petAddLeft = (CCMenuItemSprite *)m_menu->getChildByTag(100+4+leftOrRight); if (petAddLeft->getChildByTag(1000)) { petAddLeft->removeChildByTag(1000); } CCPoint leftPoint[6] = {petAddLeft->getContentSize()/2+ccp(20*gScaleX,0),petAddLeft->getContentSize()/2+ccp(20*gScaleX,0),petAddLeft->getContentSize()/2+ccp(30*gScaleX,0), petAddLeft->getContentSize()/2+ccp(30*gScaleX,0),petAddLeft->getContentSize()/2+ccp(30*gScaleX,0),petAddLeft->getContentSize()/2+ccp(30*gScaleX,0)}; float scale[6] = {0.4*PRE_SCALE,0.4*PRE_SCALE,0.5*PRE_SCALE,0.5*PRE_SCALE,0.5*PRE_SCALE,0.5*PRE_SCALE}; CCSprite *sp = NULL; if (petId != -1) { char petFile[48]; sprintf(petFile,"ui/petUI/pet%d_0.png",petId); sp = CCSprite::create(petFile); sp->setScale(scale[petId]); if(leftOrRight ==0) { sp->setPosition(leftPoint[petId]); m_leftPitId = petId; } else { sp->setPosition(leftPoint[petId]); m_rightPetId =petId; } showHeroPet(leftOrRight,petId); } else { sp = CCSprite::create("ui/shared/plus.png"); sp->setPosition(petAddLeft->getContentSize()/2+ccp(20*gScaleX,0)); if(leftOrRight ==0) { if(this->getChildByTag(45456)!=NULL) { this->getChildByTag(45456)->setVisible(false); } } else { if(this->getChildByTag(45457)!=NULL) { this->getChildByTag(45457)->setVisible(false); } } } petAddLeft->addChild(sp,1,1000); }