summaryrefslogtreecommitdiff
path: root/src/animatedsprite.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-06-03 20:06:08 +0300
committerAndrei Karas <akaras@inbox.ru>2012-06-03 20:18:49 +0300
commit98c10803f79ce9decb4a431719e18bb27aac4485 (patch)
treecbe6325a1e2deafe38170565a0c1d9c3f5cb7faa /src/animatedsprite.cpp
parent57a81ed6cf1c02d7ec8bfe1e6f0a1d3232309534 (diff)
downloadplus-98c10803f79ce9decb4a431719e18bb27aac4485.tar.gz
plus-98c10803f79ce9decb4a431719e18bb27aac4485.tar.bz2
plus-98c10803f79ce9decb4a431719e18bb27aac4485.tar.xz
plus-98c10803f79ce9decb4a431719e18bb27aac4485.zip
Improve a bit animation speed.
Diffstat (limited to 'src/animatedsprite.cpp')
-rw-r--r--src/animatedsprite.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/animatedsprite.cpp b/src/animatedsprite.cpp
index 9bf7018a3..1014fbe46 100644
--- a/src/animatedsprite.cpp
+++ b/src/animatedsprite.cpp
@@ -85,7 +85,7 @@ bool AnimatedSprite::reset()
mLastTime = 0;
if (mAnimation)
- mFrame = mAnimation->getFrame(0);
+ mFrame = &mAnimation->mFrames[0];
else
mFrame = nullptr;
return ret;
@@ -142,7 +142,8 @@ bool AnimatedSprite::update(int time)
bool AnimatedSprite::updateCurrentAnimation(unsigned int time)
{
- if (!mFrame || !mAnimation || Animation::isTerminator(*mFrame))
+ // move code from Animation::isTerminator(*mFrame)
+ if (!mFrame || !mAnimation || (!mFrame->image && mFrame->type == Frame::ANIMATION))
return false;
mFrameTime += time;
@@ -158,7 +159,7 @@ bool AnimatedSprite::updateCurrentAnimation(unsigned int time)
if (mFrameIndex >= mAnimation->getLength())
mFrameIndex = 0;
- mFrame = mAnimation->getFrame(mFrameIndex);
+ mFrame = &mAnimation->mFrames[mFrameIndex];
if (!mFrame || (mFrame->type == Frame::LABEL
&& !mFrame->nextAction.empty()))
{
@@ -170,7 +171,7 @@ bool AnimatedSprite::updateCurrentAnimation(unsigned int time)
{
for (unsigned i = 0; i < mAnimation->getLength(); i ++)
{
- Frame *frame = mAnimation->getFrame(i);
+ Frame *frame = &mAnimation->mFrames[i];
if (frame->type == Frame::LABEL
&& mFrame->nextAction == frame->nextAction)
{
@@ -179,7 +180,7 @@ bool AnimatedSprite::updateCurrentAnimation(unsigned int time)
if (mFrameIndex >= mAnimation->getLength())
mFrameIndex = 0;
- mFrame = mAnimation->getFrame(mFrameIndex);
+ mFrame = &mAnimation->mFrames[mFrameIndex];
fail = true;
break;
@@ -195,7 +196,8 @@ bool AnimatedSprite::updateCurrentAnimation(unsigned int time)
return true;
}
}
- else if (Animation::isTerminator(*mFrame))
+ // copy code from Animation::isTerminator(*mFrame)
+ else if (!mFrame->image && mFrame->type == Frame::ANIMATION)
{
if (mFrame->rand == 100 || rand() % 100 <= mFrame->rand)
{