void Detect::setCurFloor(int floorId, int towerId, float duration) { // 当前楼层返回 if(_curFloor != nullptr && floorId == _curFloor->getId() && towerId == _curFloor->getTower()->getId()) return; auto oldTower = _curTower; auto oldFloor = _curFloor; if(towerId == -1) towerId = getCurTower()->getId(); // 当前显示的楼层切换 Tower* newTower = getTower(towerId); if(_world->getChildByTag(towerId) == nullptr) { _world->addChild(newTower,towerId,towerId); newTower->setVisible(false); } Floor* newFloor = getFloor(floorId, towerId); newFloor->buildMap(); if(newTower->getChildByTag(floorId) == nullptr) { newTower->addChild(newFloor,floorId,floorId); newFloor->setVisible(false); } setControlled(4,false); _curFloor = newFloor; _curTower = newTower; //// 镜头跟随 //if(_player != nullptr) //{ // auto rect = Rect(0,0,_curFloor->getHorizonTileNum()*TILE_WIDTH,_curFloor->getVerticalTileNum()*TILE_HEIGHT); // auto follow = Follow::create(_player, rect); // _curFloor->runAction(follow); //} _worldDark->removeFromParent(); _world->addChild(_worldDark,100); _worldDark->runAction(Sequence::create(FadeTo::create(duration,180),CallFunc::create([=](){ /*for(auto node:_world->getChildren()) { if(node != _worldDark) { node->setVisible(false); } }*/ if(oldTower != nullptr) { oldTower->setVisible(false); } if(oldFloor != nullptr) { oldFloor->setVisible(false); } newTower->setVisible(true); newFloor->setVisible(true); newTower->setZOrder(-1); newFloor->setZOrder(-1); #if DETECT_ACTOR == 1 _curFloor->updateFight(); #endif EventHelper::getInstance()->dispatchByStr("target:hud|senderName:Detect|type:setCurFloor", StringUtils::format("floorId:%d|towerName:%s",floorId,_curTower->getNickName().c_str())); }),FadeTo::create(duration,0),CallFuncN::create([this](Node *node){setControlled(4,true);node->removeFromParent();}),NULL)); }