void BaseMap::loadPathFromPlist() { winSize = Director::getInstance()->getWinSize(); auto plistDic = Dictionary::createWithContentsOfFile(String::createWithFormat("level%d_paths.plist",getLevel())->getCString()); auto path_array = dynamic_cast<__Array*>(plistDic->objectForKey("paths")); for(int i = 0;i<path_array->count();i++) { std::vector<std::vector<Point>> tempPathVector; auto path_array2 = dynamic_cast<__Array*>(path_array->getObjectAtIndex(i)); for(int j = 0;j<path_array2->count();j++) { std::vector<Point> tempRandomPathVector; auto path_array3 = dynamic_cast<__Array*>(path_array2->getObjectAtIndex(j)); for(int k =0;k<path_array3->count();k++) { auto tempDic = dynamic_cast<__Dictionary*>(path_array3->getObjectAtIndex(k)); Point tempPath = Point(); tempPath.x = dynamic_cast<__String*>(tempDic->objectForKey("x"))->floatValue()*1.15; tempPath.y = dynamic_cast<__String*>(tempDic->objectForKey("y"))->floatValue()*1.20+50; tempRandomPathVector.push_back(tempPath); } tempPathVector.push_back(tempRandomPathVector); } path.push_back(tempPathVector); } }
void BaseMap::loadAndSetLevelData() { //加载初始血量金钱等 auto dataDic = Dictionary::createWithContentsOfFile(String::createWithFormat("level%d_%d_monsters.plist", getLevel(),difficulty)->getCString()); auto data_array = dynamic_cast<__Array*>(dataDic->objectForKey("data")); auto data_tempDic = dynamic_cast<__Dictionary*>(data_array->getObjectAtIndex(0)); startGold = dynamic_cast<__String*>(data_tempDic->objectForKey("gold"))->intValue(); maxLife = dynamic_cast<__String*>(data_tempDic->objectForKey("life"))->intValue(); maxWave = dynamic_cast<__String*>(data_tempDic->objectForKey("wave"))->intValue(); //加载怪物数据 auto monsters_array = dynamic_cast<__Array*>(dataDic->objectForKey("monsters")); for(int i =0 ;i < monsters_array->count();i++) { auto monster_array = dynamic_cast<__Array*>(monsters_array->getObjectAtIndex(i)); std::vector<Vector<GroupMonster*>> thisTimeMonster; for(int j =0;j<monster_array->count();j++) { auto tempArray = dynamic_cast<__Array*>(monster_array->getObjectAtIndex(j)); Vector<GroupMonster*> monsterVector; for(int k =0;k<tempArray->count();k++) { auto tempDic = dynamic_cast<__Dictionary*>(tempArray->getObjectAtIndex(k)); monsterVector.pushBack(GroupMonster::initGroupEnemy( dynamic_cast<__String*>(tempDic->objectForKey("type"))->intValue(), dynamic_cast<__String*>(tempDic->objectForKey("road"))->intValue(), dynamic_cast<__String*>(tempDic->objectForKey("path"))->intValue())); } thisTimeMonster.push_back(monsterVector); monsterVector.clear(); } waveVector.push_back(thisTimeMonster); thisTimeMonster.clear(); } }
void EditorPage::loadMissionPage(MissionPage* page) { auto interface = page->getMissionInterface(); this->_loadMissionDataInterface(interface->getMissionObjects()); auto missionCollection = interface->getMissionCollection(); auto collections = missionCollection->getCollections(); for (int i = 0; i < collections->count(); ++ i) { auto col = dynamic_cast<Collection*>(collections->getObjectAtIndex(i)); m_realCollections->addObject(col); auto pNode = col->createEditorPhysicNode(); auto pos = pNode->getPosition(); auto csize = pNode->getContentSize(); pNode->setPosition(Vec2::ZERO); auto epnc = EditorPhysicNodeContainer::create(); epnc->setEditorListener(this->getEditorListener()); epnc->setPhysicNode(pNode); epnc->setPosition(pos); epnc->setContentSize(csize); this->addChild(epnc); m_collections->addObject(epnc); } //this->_loadMissionDataInterface(interface->getMissionCollection()); }
void KeyboardNotificationLayer::keyboardWillShow(IMEKeyboardNotificationInfo& info) { CCLOG("TextInputTest:keyboardWillShowAt(origin:%f,%f, size:%f,%f)", info.end.origin.x, info.end.origin.y, info.end.size.width, info.end.size.height); if (! _trackNode) { return; } auto rectTracked = getRect(_trackNode); CCLOG("TextInputTest:trackingNodeAt(origin:%f,%f, size:%f,%f)", rectTracked.origin.x, rectTracked.origin.y, rectTracked.size.width, rectTracked.size.height); // if the keyboard area doesn't intersect with the tracking node area, nothing need to do. if (! rectTracked.intersectsRect(info.end)) { return; } // assume keyboard at the bottom of screen, calculate the vertical adjustment. float adjustVert = info.end.getMaxY() - rectTracked.getMinY(); CCLOG("TextInputTest:needAdjustVerticalPosition(%f)", adjustVert); // move all the children node of KeyboardNotificationLayer auto children = getChildren(); Node * node = 0; int count = children->count(); Point pos; for (int i = 0; i < count; ++i) { node = (Node*)children->getObjectAtIndex(i); pos = node->getPosition(); pos.y += adjustVert; node->setPosition(pos); } }