From 73432d5972f8a3d2a339260246f3a44842dac58e Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 5 Feb 2016 22:31:49 +0300 Subject: Add support for play animation in cutins. --- src/resources/sprite/animatedsprite.cpp | 16 ++++++++++++++++ src/resources/sprite/animatedsprite.h | 7 +++++++ 2 files changed, 23 insertions(+) (limited to 'src/resources') diff --git a/src/resources/sprite/animatedsprite.cpp b/src/resources/sprite/animatedsprite.cpp index 216d94106..5210ce626 100644 --- a/src/resources/sprite/animatedsprite.cpp +++ b/src/resources/sprite/animatedsprite.cpp @@ -330,6 +330,22 @@ void AnimatedSprite::draw(Graphics *restrict const graphics, posX + mFrame->offsetX, posY + mFrame->offsetY); } +void AnimatedSprite::drawRaw(Graphics *restrict const graphics, + const int posX, + const int posY) const restrict2 +{ + if (!mFrame || !mFrame->image) + return; + + Image *restrict const image = mFrame->image; + if (image->getAlpha() != mAlpha) + image->setAlpha(mAlpha); + + graphics->drawImage(image, + posX, + posY); +} + bool AnimatedSprite::setSpriteDirection(const SpriteDirection::Type direction) restrict2 { diff --git a/src/resources/sprite/animatedsprite.h b/src/resources/sprite/animatedsprite.h index 53423b77a..2a40df1e9 100644 --- a/src/resources/sprite/animatedsprite.h +++ b/src/resources/sprite/animatedsprite.h @@ -73,6 +73,10 @@ class AnimatedSprite final : public Sprite const int posX, const int posY) const restrict2 override final A_NONNULL(2); + void drawRaw(Graphics *restrict const graphics, + const int posX, + const int posY) const restrict2 A_NONNULL(2); + int getWidth() const restrict2 override final A_WARN_UNUSED; int getHeight() const restrict2 override final A_WARN_UNUSED; @@ -116,6 +120,9 @@ class AnimatedSprite final : public Sprite void setLastTime(const int time) noexcept { mLastTime = time; } + const Frame *getFrame() const restrict2 + { return mFrame; } + #ifdef UNITTESTS SpriteDef *getSprite() restrict2 { return mSprite; } -- cgit v1.2.3-70-g09d2