Esempio n. 1
0
bool MapScene::init()
{
	if (!Layer::create())
	{
		return false;
	}
	/*╪стьмъф╛╣ьм╪*/

	switch (this->step)
	{
	case 1:{
			   std::string file = "Map.tmx";
			   auto str = String::createWithContentsOfFile(FileUtils::getInstance()->fullPathForFilename(file.c_str()).c_str());
			   this->map = TMXTiledMap::createWithXML(str->getCString(), "");
			   TMXLayer* obscatle= map->layerNamed("obscatle");
			   obscatle->setVisible(false);
			   this->objGroup = map->getObjectGroup("Object");
			   this->addChild(map, 0);
	}break;
	case 2:{
			   std::string file = "MapStep2.tmx";
			   auto str = String::createWithContentsOfFile(FileUtils::getInstance()->fullPathForFilename(file.c_str()).c_str());
			   this->map = TMXTiledMap::createWithXML(str->getCString(), "");
			   TMXLayer* obscatle = map->layerNamed("obscatle");
			   obscatle->setVisible(false);
			   this->objGroup = map->getObjectGroup("Object"); 
			   this->addChild(map, 0);

	}break;
	case 3:{
			   std::string file = "MapStep3.tmx";
			   auto str = String::createWithContentsOfFile(FileUtils::getInstance()->fullPathForFilename(file.c_str()).c_str());
			   this->map = TMXTiledMap::createWithXML(str->getCString(), "");
			   TMXLayer* obscatle = map->layerNamed("obscatle");
			   obscatle->setVisible(false);
			   this->objGroup = map->getObjectGroup("Object");
			   this->addChild(map, 0);

	}break;
	default:
		break;
	}

	
	
	return true;
}
Esempio n. 2
0
/**
 *加载地图
*/
void HelloWorld::loadMap(const std::string& mapName)
{
    String* mapXml = String::createWithContentsOfFile("gamemap.tmx");
    m_gamemap = TMXTiledMap::createWithXML(mapXml->getCString(), "");
    assert(m_gamemap);
    TMXLayer* layer = m_gamemap->layerNamed("block");
    if (layer != NULL)
        layer->setVisible(false);

    this->addChild(m_gamemap);
}