summaryrefslogtreecommitdiff
path: root/src/resources/spritedef.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-04-13 03:36:00 +0300
committerAndrei Karas <akaras@inbox.ru>2011-04-13 03:36:00 +0300
commitc978b7f0d9de1bb6bd84cd299ed80c27c5147927 (patch)
tree8f1edc2be0816693761ba58aa7c7c554040a7db6 /src/resources/spritedef.cpp
parentda1b2d8311ca78eccd3e9875598562ce6bf05cab (diff)
downloadmanaplus-c978b7f0d9de1bb6bd84cd299ed80c27c5147927.tar.gz
manaplus-c978b7f0d9de1bb6bd84cd299ed80c27c5147927.tar.bz2
manaplus-c978b7f0d9de1bb6bd84cd299ed80c27c5147927.tar.xz
manaplus-c978b7f0d9de1bb6bd84cd299ed80c27c5147927.zip
Impliment new tags in sprites animations and random condition.
Tags: <label>, <goto>
Diffstat (limited to 'src/resources/spritedef.cpp')
-rw-r--r--src/resources/spritedef.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp
index e6a65926e..1eea6547d 100644
--- a/src/resources/spritedef.cpp
+++ b/src/resources/spritedef.cpp
@@ -225,6 +225,8 @@ void SpriteDef::loadAnimation(xmlNodePtr animationNode,
imageSet->getOffsetX();
int offsetY = XML::getProperty(frameNode, "offsetY", 0) +
imageSet->getOffsetY();
+ int rand = XML::getProperty(frameNode, "rand", 100);
+
offsetY -= imageSet->getHeight() - 32;
offsetX -= imageSet->getWidth() / 2 - 16;
@@ -246,7 +248,7 @@ void SpriteDef::loadAnimation(xmlNodePtr animationNode,
continue;
}
- animation->addFrame(img, delay, offsetX, offsetY);
+ animation->addFrame(img, delay, offsetX, offsetY, rand);
}
else if (xmlStrEqual(frameNode->name, BAD_CAST "sequence"))
{
@@ -282,7 +284,7 @@ void SpriteDef::loadAnimation(xmlNodePtr animationNode,
continue;
}
- animation->addFrame(img, delay, offsetX, offsetY);
+ animation->addFrame(img, delay, offsetX, offsetY, rand);
pos ++;
}
repeat --;
@@ -290,11 +292,24 @@ void SpriteDef::loadAnimation(xmlNodePtr animationNode,
}
else if (xmlStrEqual(frameNode->name, BAD_CAST "end"))
{
- animation->addTerminator();
+ animation->addTerminator(rand);
}
else if (xmlStrEqual(frameNode->name, BAD_CAST "jump"))
{
- animation->addJump(XML::getProperty(frameNode, "action", ""));
+ animation->addJump(XML::getProperty(
+ frameNode, "action", ""), rand);
+ }
+ else if (xmlStrEqual(frameNode->name, BAD_CAST "label"))
+ {
+ std::string name = XML::getProperty(frameNode, "name", "");
+ if (!name.empty())
+ animation->addLabel(name);
+ }
+ else if (xmlStrEqual(frameNode->name, BAD_CAST "goto"))
+ {
+ std::string name = XML::getProperty(frameNode, "label", "");
+ if (!name.empty())
+ animation->addGoto(name, rand);
}
} // for frameNode
}