diff options
-rw-r--r-- | src/compoundsprite.cpp | 9 | ||||
-rw-r--r-- | src/compoundsprite.h | 15 |
2 files changed, 10 insertions, 14 deletions
diff --git a/src/compoundsprite.cpp b/src/compoundsprite.cpp index 0ca55098..8193d8c0 100644 --- a/src/compoundsprite.cpp +++ b/src/compoundsprite.cpp @@ -74,8 +74,7 @@ bool CompoundSprite::update(int time) bool CompoundSprite::draw(Graphics *graphics, int posX, int posY) const { - if (mNeedsRedraw) - redraw(); + doRedraw(); if (mSprites.empty()) // Nothing to draw return false; @@ -163,12 +162,6 @@ void CompoundSprite::ensureSize(size_t layerCount) mSprites.resize(layerCount); } -void CompoundSprite::doRedraw() -{ - if (mNeedsRedraw) - redraw(); -} - int CompoundSprite::getMaxDuration() const { int duration = 0; diff --git a/src/compoundsprite.h b/src/compoundsprite.h index cea0b11f..5aa11686 100644 --- a/src/compoundsprite.h +++ b/src/compoundsprite.h @@ -38,15 +38,12 @@ public: /** * Gets the width in pixels of the first sprite in the list. */ - int getWidth() const { return mWidth; } + int getWidth() const { doRedraw(); return mWidth; } /** * Gets the height in pixels of the first sprite in the list. */ - int getHeight() const { return mHeight; } - - int getOffsetX() const { return mOffsetX; } - int getOffsetY() const { return mOffsetY; } + int getHeight() const { doRedraw(); return mHeight; } float getAlpha() const { return mAlpha; } void setAlpha(float alpha) { mAlpha = alpha; } @@ -64,7 +61,7 @@ public: void clear(); void ensureSize(size_t layerCount); - void doRedraw(); + void doRedraw() const; private: void redraw() const; @@ -80,3 +77,9 @@ private: float mAlpha = 1.0f; std::vector<Sprite*> mSprites; }; + +inline void CompoundSprite::doRedraw() const +{ + if (mNeedsRedraw) + redraw(); +} |