From ec980b3c586fc64d02ad02f31497013908056d52 Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Tue, 8 Jun 2010 21:55:16 -0600 Subject: Remove hard-coded frame counts from Being class Also removes the Monster/Player difference in tmwAthena's Being::logic and moves the particle code from Being::setAttack to Being::Logic for tmwAthena. Reviewed-by: Chuck Miller --- src/compoundsprite.cpp | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'src/compoundsprite.cpp') 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 -- cgit v1.2.3-70-g09d2