diff options
author | Björn Steinbrink <B.Steinbrink@gmx.de> | 2006-08-04 18:04:12 +0000 |
---|---|---|
committer | Björn Steinbrink <B.Steinbrink@gmx.de> | 2006-08-04 18:04:12 +0000 |
commit | 9d76e6b415c665686ee52c1979ad4d0be79cd111 (patch) | |
tree | 3a2b515a6de4967706d4181b5ad407cddad9669a /src/animatedsprite.cpp | |
parent | 87c52c1d627260e6e3ce743e48f8fa242547b521 (diff) | |
download | mana-9d76e6b415c665686ee52c1979ad4d0be79cd111.tar.gz mana-9d76e6b415c665686ee52c1979ad4d0be79cd111.tar.bz2 mana-9d76e6b415c665686ee52c1979ad4d0be79cd111.tar.xz mana-9d76e6b415c665686ee52c1979ad4d0be79cd111.zip |
Small code cleanup/lower indentation.
Diffstat (limited to 'src/animatedsprite.cpp')
-rw-r--r-- | src/animatedsprite.cpp | 71 |
1 files changed, 35 insertions, 36 deletions
diff --git a/src/animatedsprite.cpp b/src/animatedsprite.cpp index 02acc8be..cc8399a4 100644 --- a/src/animatedsprite.cpp +++ b/src/animatedsprite.cpp @@ -114,47 +114,46 @@ AnimatedSprite::AnimatedSprite(const std::string& animationFile, int variant): animationNode != NULL; animationNode = animationNode->next) { - if (xmlStrEqual(animationNode->name, BAD_CAST "animation")) + // We're only interested in animations + if (!xmlStrEqual(animationNode->name, BAD_CAST "animation")) + continue; + + std::string dir = getProperty(animationNode, "direction", ""); + Animation *animation = new Animation(); + action->setAnimation(makeSpriteDirection(dir), animation); + + // Get animation phases + for (xmlNodePtr phaseNode = animationNode->xmlChildrenNode; + phaseNode != NULL; + phaseNode = phaseNode->next) { - std::string direction = - getProperty(animationNode, "direction", ""); + int delay = getProperty(phaseNode, "delay", 0); - Animation *animation = new Animation(); - - // Get animation phases - for (xmlNodePtr phaseNode = animationNode->xmlChildrenNode; - phaseNode != NULL; - phaseNode = phaseNode->next) + if (xmlStrEqual(phaseNode->name, BAD_CAST "frame")) { - int delay = getProperty(phaseNode, "delay", 0); - - if (xmlStrEqual(phaseNode->name, BAD_CAST "frame")) - { - int index = getProperty(phaseNode, "index", -1); - int offsetX = getProperty(phaseNode, "offsetX", 0); - int offsetY = getProperty(phaseNode, "offsetY", 0); - - offsetY -= mSpritesets[imageset]->getHeight() - 32; - offsetX -= mSpritesets[imageset]->getWidth() / 2 - 16; - animation->addPhase(index + variant_offset, delay, - offsetX, offsetY); - } - else if (xmlStrEqual(phaseNode->name, BAD_CAST "sequence")) + int index = getProperty(phaseNode, "index", -1); + int offsetX = getProperty(phaseNode, "offsetX", 0); + int offsetY = getProperty(phaseNode, "offsetY", 0); + + offsetY -= mSpritesets[imageset]->getHeight() - 32; + offsetX -= mSpritesets[imageset]->getWidth() / 2 - 16; + animation->addPhase(index + variant_offset, delay, + offsetX, offsetY); + } + else if (xmlStrEqual(phaseNode->name, BAD_CAST "sequence")) + { + int start = getProperty(phaseNode, "start", 0); + int end = getProperty(phaseNode, "end", 0); + int offsetY = -mSpritesets[imageset]->getHeight() + 32; + int offsetX = -mSpritesets[imageset]->getWidth() / 2 + 16; + while (end >= start) { - int start = getProperty(phaseNode, "start", 0); - int end = getProperty(phaseNode, "end", 0); - int offsetY = -mSpritesets[imageset]->getHeight() + 32; - int offsetX = -mSpritesets[imageset]->getWidth() / 2 + 16; - while (end >= start) - { - animation->addPhase(start + variant_offset, - delay, offsetX, offsetY); - start++; - } + animation->addPhase(start + variant_offset, + delay, offsetX, offsetY); + start++; } - } // for phaseNode - action->setAnimation(makeSpriteDirection(direction), animation); - } // if "<animation>" + } + } // for phaseNode } // for animationNode } // if "<imageset>" else if "<action>" } // for node |