Mana
Loading...
Searching...
No Matches
simpleanimation.h
Go to the documentation of this file.
1/*
2 * The Mana Client
3 * Copyright (C) 2004-2009 The Mana World Development Team
4 * Copyright (C) 2009-2012 The Mana Developers
5 *
6 * This file is part of The Mana Client.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#pragma once
23
24#include "resources/animation.h"
25
26#include "utils/xml.h"
27
28class Graphics;
29
34class SimpleAnimation final
35{
36 public:
41 SimpleAnimation(Animation animation);
42
46 SimpleAnimation(XML::Node animationNode,
47 const std::string &dyePalettes = std::string());
48
49 void setFrame(int frame);
50
51 int getLength() const { return mAnimation.getLength(); }
52
53 void update(int dt);
54
55 bool draw(Graphics *graphics, int posX, int posY) const;
56
60 void reset();
61
62 Image *getCurrentImage() const;
63
64 private:
67
70
73
75 Frame *mCurrentFrame = nullptr;
76
78 bool mInitialized = false;
79};
An animation consists of several frames, each with their own delay and offset.
Definition animation.h:47
int getLength() const
Returns the length of this animation in frames.
Definition animation.h:70
A central point of control for graphics.
Definition graphics.h:78
Defines a class for loading and storing images.
Definition image.h:45
This class is a leightweight alternative to the Sprite class.
Frame * mCurrentFrame
Current animation phase.
int mAnimationTime
Time in milliseconds the current frame is shown.
int mAnimationPhase
Index of current animation phase.
bool mInitialized
Tell whether the animation is ready.
int getLength() const
Image * getCurrentImage() const
void update(int dt)
bool draw(Graphics *graphics, int posX, int posY) const
void setFrame(int frame)
Animation mAnimation
The hosted animation.
void reset()
Resets the animation.
Graphics * graphics
Definition client.cpp:104
A single frame in an animation, with a delay and an offset.
Definition animation.h:35