summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-03-27 19:23:52 +0300
committerAndrei Karas <akaras@inbox.ru>2012-03-27 19:23:52 +0300
commita199f1aa431f872bc13c5df5a9afad0e52a1ee1d (patch)
treed98bc9d256f98714f0d9ebf635e7043900a10d58
parent3d24b9f024dc9114165530aa58dc4a7832ca2753 (diff)
downloadplus-a199f1aa431f872bc13c5df5a9afad0e52a1ee1d.tar.gz
plus-a199f1aa431f872bc13c5df5a9afad0e52a1ee1d.tar.bz2
plus-a199f1aa431f872bc13c5df5a9afad0e52a1ee1d.tar.xz
plus-a199f1aa431f872bc13c5df5a9afad0e52a1ee1d.zip
Add pause animation tag.
Example: <pause delay="10"/>
-rw-r--r--src/animatedsprite.cpp3
-rw-r--r--src/resources/animation.cpp6
-rw-r--r--src/resources/animation.h5
-rw-r--r--src/resources/spritedef.cpp4
4 files changed, 16 insertions, 2 deletions
diff --git a/src/animatedsprite.cpp b/src/animatedsprite.cpp
index 6b791fdd4..136bea946 100644
--- a/src/animatedsprite.cpp
+++ b/src/animatedsprite.cpp
@@ -146,7 +146,8 @@ bool AnimatedSprite::updateCurrentAnimation(unsigned int time)
mFrameTime += time;
while ((mFrameTime > static_cast<unsigned>(mFrame->delay)
- && mFrame->delay > 0) || mFrame->type != Frame::ANIMATION)
+ && mFrame->delay > 0) || (mFrame->type != Frame::ANIMATION
+ && mFrame->type != Frame::PAUSE))
{
bool fail(true);
mFrameTime -= static_cast<unsigned>(mFrame->delay);
diff --git a/src/resources/animation.cpp b/src/resources/animation.cpp
index 388c1301e..853b79d64 100644
--- a/src/resources/animation.cpp
+++ b/src/resources/animation.cpp
@@ -70,6 +70,12 @@ void Animation::addGoto(std::string name, int rand)
mFrames.push_back(frame);
}
+void Animation::addPause(int delay, int rand)
+{
+ Frame frame = { nullptr, delay, 0, 0, rand, Frame::PAUSE, "" };
+ mFrames.push_back(frame);
+}
+
void Animation::setLastFrameDelay(int delay)
{
FramesRevIter it = mFrames.rbegin();
diff --git a/src/resources/animation.h b/src/resources/animation.h
index 53e9adbea..1d23b1608 100644
--- a/src/resources/animation.h
+++ b/src/resources/animation.h
@@ -40,7 +40,8 @@ struct Frame
ANIMATION = 0,
JUMP,
GOTO,
- LABEL
+ LABEL,
+ PAUSE
};
Image *image;
int delay;
@@ -102,6 +103,8 @@ class Animation
void addGoto(std::string name, int rand);
+ void addPause(int delay, int rand);
+
void setLastFrameDelay(int delay);
/**
diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp
index 02b46f1cf..a4ebc6f7e 100644
--- a/src/resources/spritedef.cpp
+++ b/src/resources/spritedef.cpp
@@ -340,6 +340,10 @@ void SpriteDef::loadAnimation(XmlNodePtr animationNode,
repeat --;
}
}
+ else if (xmlNameEqual(frameNode, "pause"))
+ {
+ animation->addPause(delay, rand);
+ }
else if (xmlNameEqual(frameNode, "end"))
{
animation->addTerminator(rand);