From 3968453eb82521f6ab3966ff1dc08cd0c803d359 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 9 Apr 2011 03:13:43 +0300 Subject: Add enum to animation actions support. --- src/animatedsprite.cpp | 2 +- src/resources/animation.cpp | 4 ++-- src/resources/animation.h | 7 +++++++ 3 files changed, 10 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/animatedsprite.cpp b/src/animatedsprite.cpp index 10bb05cf8..b9946fb1d 100644 --- a/src/animatedsprite.cpp +++ b/src/animatedsprite.cpp @@ -159,7 +159,7 @@ bool AnimatedSprite::updateCurrentAnimation(unsigned int time) mFrame = 0; return false; } - if (!mFrame->nextAction.empty()) + if (mFrame->type == Frame::JUMP && !mFrame->nextAction.empty()) { play(mFrame->nextAction); return true; diff --git a/src/resources/animation.cpp b/src/resources/animation.cpp index fe5822f7b..98ea19f2a 100644 --- a/src/resources/animation.cpp +++ b/src/resources/animation.cpp @@ -31,7 +31,7 @@ Animation::Animation(): void Animation::addFrame(Image *image, int delay, int offsetX, int offsetY) { - Frame frame = { image, delay, offsetX, offsetY, "" }; + Frame frame = { image, delay, offsetX, offsetY, Frame::ANIMATION, "" }; mFrames.push_back(frame); mDuration += delay; } @@ -48,6 +48,6 @@ bool Animation::isTerminator(const Frame &candidate) void Animation::addJump(std::string name) { - Frame frame = { 0, 0, 0, 0, name }; + Frame frame = { 0, 0, 0, 0, Frame::JUMP, name }; mFrames.push_back(frame); } diff --git a/src/resources/animation.h b/src/resources/animation.h index 9ec8396af..5130bc8dd 100644 --- a/src/resources/animation.h +++ b/src/resources/animation.h @@ -35,10 +35,17 @@ class Image; */ struct Frame { + enum FrameType + { + ANIMATION = 0, + JUMP, + LABEL + }; Image *image; int delay; int offsetX; int offsetY; + FrameType type; std::string nextAction; }; -- cgit v1.2.3-70-g09d2