diff options
-rw-r--r-- | src/resources/imageset.cpp | 5 | ||||
-rw-r--r-- | src/resources/imageset.h | 14 | ||||
-rw-r--r-- | src/resources/spritedef.cpp | 8 |
3 files changed, 24 insertions, 3 deletions
diff --git a/src/resources/imageset.cpp b/src/resources/imageset.cpp index c3994b3b..9fe75395 100644 --- a/src/resources/imageset.cpp +++ b/src/resources/imageset.cpp @@ -27,7 +27,10 @@ #include "utils/dtor.h" -ImageSet::ImageSet(Image *img, int width, int height, int margin, int spacing) +ImageSet::ImageSet(Image *img, int width, int height, + int margin, int spacing) : + mOffsetX(0), + mOffsetY(0) { for (int y = margin; y + height <= img->getHeight() - margin; y += height + spacing) { diff --git a/src/resources/imageset.h b/src/resources/imageset.h index 55031732..5d9bdc2e 100644 --- a/src/resources/imageset.h +++ b/src/resources/imageset.h @@ -56,11 +56,25 @@ class ImageSet : public Resource size_type size() const { return mImages.size(); } + int getOffsetX() const + { return mOffsetX; } + + void setOffsetX(int n) + { mOffsetX = n; } + + int getOffsetY() const + { 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 405d147c..c1f74ec8 100644 --- a/src/resources/spritedef.cpp +++ b/src/resources/spritedef.cpp @@ -164,6 +164,8 @@ void SpriteDef::loadImageSet(xmlNodePtr node, const std::string &palettes) logger->error("Couldn't load imageset!"); } + imageSet->setOffsetX(XML::getProperty(node, "offsetX", 0)); + imageSet->setOffsetY(XML::getProperty(node, "offsetY", 0)); mImageSets[name] = imageSet; } @@ -229,8 +231,10 @@ void SpriteDef::loadAnimation(xmlNodePtr animationNode, { const int delay = XML::getProperty(frameNode, "delay", DEFAULT_FRAME_DELAY); - int offsetX = XML::getProperty(frameNode, "offsetX", 0); - int offsetY = XML::getProperty(frameNode, "offsetY", 0); + int offsetX = XML::getProperty(frameNode, "offsetX", 0) + + imageSet->getOffsetX(); + int offsetY = XML::getProperty(frameNode, "offsetY", 0) + + imageSet->getOffsetY(); if (xmlStrEqual(frameNode->name, BAD_CAST "frame")) { |