1
/*
2
 *  The Mana World
3
 *  Copyright (C) 2004  The Mana World Development Team
4
 *
5
 *  This file is part of The Mana World.
6
 *
7
 *  This program is free software; you can redistribute it and/or modify
8
 *  it under the terms of the GNU General Public License as published by
9
 *  the Free Software Foundation; either version 2 of the License, or
10
 *  any later version.
11
 *
12
 *  This program is distributed in the hope that it will be useful,
13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *  GNU General Public License for more details.
16
 *
17
 *  You should have received a copy of the GNU General Public License
18
 *  along with this program; if not, write to the Free Software
19
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20
 */
21
22
#ifndef SIMPLEANIMAION_H
23
#define SIMPLEANIMAION_H
24
25
#include "utils/xml.h"
26
27
class Animation;
28
class Frame;
29
class Graphics;
30
class Image;
31
32
/**
33
 * This class is a leightweight alternative to the AnimatedSprite class.
34
 * It hosts a looping animation without actions and directions.
35
 */
36
class SimpleAnimation
37
{
38
    public:
39
        /**
40
         * Creates a simple animation with an already created animation.
41
         */
42
        SimpleAnimation(Animation *animation);
43
44
        /**
45
         * Creates a simple animation that creates its animation from XML Data.
46
         */
47
        SimpleAnimation(xmlNodePtr animationNode);
48
49
        ~SimpleAnimation();
50
51
        void setFrame(int frame);
52
53
        int getLength() const;
54
55
        void update(int timePassed);
56
57
        bool draw(Graphics* graphics, int posX, int posY) const;
58
59
        /**
60
         * Resets the animation.
61
         */
62
        void reset();
63
64
        Image *getCurrentImage() const;
65
66
    private:
67
        /** The hosted animation. */
68
        Animation *mAnimation;
69
70
        /** Time in game ticks the current frame is shown. */
71
        int mAnimationTime;
72
73
        /** Index of current animation phase. */
74
        int mAnimationPhase;
75
76
        /** Current animation phase. */
77
        Frame *mCurrentFrame;
78
};
79
80
#endif