tiledmap read data

This commit is contained in:
songhao 2018-08-21 03:12:23 -04:00
parent 915003be08
commit 15e11666b5
2 changed files with 8 additions and 3 deletions

View File

@ -52,6 +52,9 @@ bool TiledMap::LoadTmxFile(const std::string& filename)
std::shared_ptr<a8::XObject> prop_node = prop_nodes->At(j); std::shared_ptr<a8::XObject> prop_node = prop_nodes->At(j);
layer.prop_hash[prop_node->At("attrs.name")->AsXValue()] = prop_node->At("attrs.value")->AsXValue(); layer.prop_hash[prop_node->At("attrs.name")->AsXValue()] = prop_node->At("attrs.value")->AsXValue();
} }
std::shared_ptr<a8::XObject> data_node = layer_node->At("child_node.data")->At(0);
layer.data = data_node->At("node_value")->AsXValue();
} }
std::string layer_name = layer_node->At("attrs.name")->AsXValue(); std::string layer_name = layer_node->At("attrs.name")->AsXValue();
@ -110,6 +113,7 @@ void TiledMap::Dump()
for (auto& pair : layer_hash) { for (auto& pair : layer_hash) {
a8::XPrintf(" layer$layer_type:%s\n", {pair.first}); a8::XPrintf(" layer$layer_type:%s\n", {pair.first});
for (auto& layer : pair.second) { for (auto& layer : pair.second) {
a8::XPrintf("data$data:%s\n",{layer.data});
for (auto& pair2 : layer.prop_hash) { for (auto& pair2 : layer.prop_hash) {
a8::XPrintf(" layer$%s:%s\n", {pair2.first, pair2.second}); a8::XPrintf(" layer$%s:%s\n", {pair2.first, pair2.second});
} }

View File

@ -19,6 +19,7 @@ class TiledLayer
public: public:
std::map<std::string, a8::XValue> prop_hash; std::map<std::string, a8::XValue> prop_hash;
a8::XValue data;
}; };
class TiledMap class TiledMap