summaryrefslogtreecommitdiff
path: root/src/animatedsprite.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/animatedsprite.cpp')
-rw-r--r--src/animatedsprite.cpp18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/animatedsprite.cpp b/src/animatedsprite.cpp
index c1e89ff0..466779fd 100644
--- a/src/animatedsprite.cpp
+++ b/src/animatedsprite.cpp
@@ -54,20 +54,14 @@ AnimatedSprite::AnimatedSprite(SpriteDef *sprite):
play(ACTION_STAND);
}
-AnimatedSprite::AnimatedSprite(const std::string& filename, int variant):
- mDirection(DIRECTION_DOWN),
- mLastTime(0),
- mFrameIndex(0),
- mFrameTime(0),
- mAnimation(0),
- mFrame(0)
+AnimatedSprite *AnimatedSprite::load(const std::string& filename, int variant)
{
ResourceManager *resman = ResourceManager::getInstance();
- mSprite = resman->getSprite(filename, variant);
- assert(mSprite);
-
- // Play the stand animation by default
- play(ACTION_STAND);
+ SpriteDef *s = resman->getSprite(filename, variant);
+ if (!s) return NULL;
+ AnimatedSprite *as = new AnimatedSprite(s);
+ s->decRef();
+ return as;
}
AnimatedSprite::~AnimatedSprite()