diff options
Diffstat (limited to 'src/compoundsprite.cpp')
-rw-r--r-- | src/compoundsprite.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/compoundsprite.cpp b/src/compoundsprite.cpp index d6731e5d..d1c6cd57 100644 --- a/src/compoundsprite.cpp +++ b/src/compoundsprite.cpp @@ -187,6 +187,26 @@ int CompoundSprite::getNumberOfLayers() const } } +size_t CompoundSprite::getCurrentFrame() const +{ + SpriteConstIterator it, it_end; + for (it = begin(), it_end = end(); it != it_end; it++) + if (*it) + return (*it)->getCurrentFrame(); + + return 0; +} + +size_t CompoundSprite::getFrameCount() const +{ + SpriteConstIterator it, it_end; + for (it = begin(), it_end = end(); it != it_end; it++) + if (*it) + return (*it)->getFrameCount(); + + return 0; +} + void CompoundSprite::addSprite(Sprite* sprite) { push_back(sprite); @@ -236,6 +256,36 @@ void CompoundSprite::ensureSize(size_t layerCount) mNeedsRedraw = true; } +/** + * Returns the curent frame in the current animation of the given layer. + */ +size_t CompoundSprite::getCurrentFrame(size_t layer) +{ + if (layer >= size()) + return 0; + + Sprite *s = getSprite(layer); + if (s) + return s->getCurrentFrame(); + + return 0; +} + +/** + * Returns the frame count in the current animation of the given layer. + */ +size_t CompoundSprite::getFrameCount(size_t layer) +{ + if (layer >= size()) + return 0; + + Sprite *s = getSprite(layer); + if (s) + return s->getFrameCount(); + + return 0; +} + void CompoundSprite::redraw() const { // TODO OpenGL support |