commit 63c01ac9
Load the tilesets based on source
Changed files
| M | src/saland/model/World.cpp before |
diff --git a/src/saland/model/World.cpp b/src/saland/model/World.cpp
index 0d3640d..fd09826 100644
--- a/src/saland/model/World.cpp
+++ b/src/saland/model/World.cpp
@@ -144,11 +144,15 @@ void World::init_physics(std::shared_ptr<b2World>& world) {
void World::init(std::shared_ptr<b2World>& world, const std::string& mapFileName) {
this->physicsWorld = world;
- std::string tsx_file = sago::GetFileContent("maps/terrain.tsx");
std::string tmx_file = sago::GetFileContent(mapFileName);
- ts = sago::tiled::string2tileset(tsx_file);
tm = sago::tiled::string2tilemap(tmx_file);
- tm.tileset.at(0).alternativeSource = &ts;
+ for (size_t i = 0; i < tm.tileset.size(); ++i) {
+ if (tm.tileset[i].source.length()) {
+ std::string tsx_file = sago::GetFileContent("maps/"+tm.tileset[i].source);
+ ts = sago::tiled::string2tileset(tsx_file);
+ tm.tileset[i].alternativeSource = &ts;
+ }
+ }
init_physics(world);
}