diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2008-10-04 22:08:56 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2008-10-04 22:08:56 +0000 |
commit | 001c91ff66818a0f1a6839df2ba2a1c4d3220160 (patch) | |
tree | 35885d717c98e5fc087ac97fbfc2f078db36e7cb /src/resources | |
parent | 72c678ca1fe7ca1401efaf59c321380b4bfc6ba2 (diff) | |
download | mana-client-001c91ff66818a0f1a6839df2ba2a1c4d3220160.tar.gz mana-client-001c91ff66818a0f1a6839df2ba2a1c4d3220160.tar.bz2 mana-client-001c91ff66818a0f1a6839df2ba2a1c4d3220160.tar.xz mana-client-001c91ff66818a0f1a6839df2ba2a1c4d3220160.zip |
Added support for object groups that have an offset
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/mapreader.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index af3fc0ef..eacbb0d8 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -237,6 +237,12 @@ MapReader::readMap(xmlNodePtr node, const std::string &path) } else if (xmlStrEqual(childNode->name, BAD_CAST "objectgroup")) { + // The object group offset is applied to each object individually + const int tileOffsetX = XML::getProperty(childNode, "x", 0); + const int tileOffsetY = XML::getProperty(childNode, "y", 0); + const int offsetX = tileOffsetX * tw; + const int offsetY = tileOffsetY * th; + for_each_xml_child_node(objectNode, childNode) { if (xmlStrEqual(objectNode->name, BAD_CAST "object")) @@ -257,7 +263,8 @@ MapReader::readMap(xmlNodePtr node, const std::string &path) const int objY = XML::getProperty(objectNode, "y", 0); logger->log("- Loading object name: %s type: %s at %d:%d", - objName.c_str(), objType.c_str(), objX, objY); + objName.c_str(), objType.c_str(), + objX, objY); if (objType == "PARTICLE_EFFECT") { @@ -266,7 +273,9 @@ MapReader::readMap(xmlNodePtr node, const std::string &path) continue; } - map->addParticleEffect(objName, objX, objY); + map->addParticleEffect(objName, + objX + offsetX, + objY + offsetY); } else { @@ -318,8 +327,8 @@ MapReader::readLayer(xmlNodePtr node, Map *map) // Layers are not necessarily the same size as the map const int w = XML::getProperty(node, "width", map->getWidth()); const int h = XML::getProperty(node, "height", map->getHeight()); - const int offsetX = XML::getProperty(node, "xoffset", 0); - const int offsetY = XML::getProperty(node, "yoffset", 0); + const int offsetX = XML::getProperty(node, "x", 0); + const int offsetY = XML::getProperty(node, "y", 0); const std::string name = XML::getProperty(node, "name", ""); const bool isFringeLayer = (name == "Fringe"); |