summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/imageset.h14
-rw-r--r--src/resources/spritedef.cpp8
2 files changed, 20 insertions, 2 deletions
diff --git a/src/resources/imageset.h b/src/resources/imageset.h
index 9ca8bb678..fd320295a 100644
--- a/src/resources/imageset.h
+++ b/src/resources/imageset.h
@@ -63,11 +63,25 @@ class ImageSet : public Resource
size_type size() const
{ return mImages.size(); }
+ int getOffsetX()
+ { return mOffsetX; }
+
+ void setOffsetX(int n)
+ { mOffsetX = n; }
+
+ int getOffsetY()
+ { return mOffsetY; }
+
+ void setOffsetY(int n)
+ { mOffsetY = n; }
+
private:
std::vector<Image*> mImages;
int mHeight; /**< Height of the images in the image set. */
int mWidth; /**< Width of the images in the image set. */
+ int mOffsetX;
+ int mOffsetY;
};
#endif
diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp
index b3b473cd7..db1c3d0c3 100644
--- a/src/resources/spritedef.cpp
+++ b/src/resources/spritedef.cpp
@@ -152,6 +152,8 @@ void SpriteDef::loadImageSet(xmlNodePtr node, const std::string &palettes)
return;
}
+ imageSet->setOffsetX(XML::getProperty(node, "offsetX", 0));
+ imageSet->setOffsetY(XML::getProperty(node, "offsetY", 0));
mImageSets[name] = imageSet;
}
@@ -219,8 +221,10 @@ void SpriteDef::loadAnimation(xmlNodePtr animationNode,
for_each_xml_child_node(frameNode, animationNode)
{
const int delay = XML::getProperty(frameNode, "delay", 0);
- int offsetX = XML::getProperty(frameNode, "offsetX", 0);
- int offsetY = XML::getProperty(frameNode, "offsetY", 0);
+ int offsetX = XML::getProperty(frameNode, "offsetX",
+ imageSet->getOffsetX());
+ int offsetY = XML::getProperty(frameNode, "offsetY",
+ imageSet->getOffsetY());
offsetY -= imageSet->getHeight() - 32;
offsetX -= imageSet->getWidth() / 2 - 16;