ManaPlus
sprite.h
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2010 The Mana Developers
4  * Copyright (C) 2011-2017 The ManaPlus Developers
5  *
6  * This file is part of The ManaPlus 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 #ifndef RESOURCES_SPRITE_SPRITE_H
23 #define RESOURCES_SPRITE_SPRITE_H
24 
26 
27 #include "localconsts.h"
28 
29 class Graphics;
30 class Image;
31 
33 {
34  public:
36 
37  virtual ~Sprite()
38  { }
39 
45  virtual bool reset() = 0;
46 
52  virtual bool play(const std::string &action) = 0;
53 
60  virtual bool update(const int time) = 0;
61 
66  virtual void draw(Graphics *const graphics,
67  const int posX, const int posY)
68  const A_NONNULL(2) = 0;
69 
73  virtual int getWidth() const A_WARN_UNUSED = 0;
74 
78  virtual int getHeight() const A_WARN_UNUSED = 0;
79 
83  virtual const Image* getImage() const A_WARN_UNUSED = 0;
84 
90  virtual bool setSpriteDirection(const SpriteDirection::Type
91  direction) = 0;
92 
96  virtual void setAlpha(float alpha)
97  { mAlpha = alpha; }
98 
102  virtual float getAlpha() const A_WARN_UNUSED
103  { return mAlpha; }
104 
108  virtual unsigned int getCurrentFrame() const A_WARN_UNUSED = 0;
109 
113  virtual unsigned int getFrameCount() const A_WARN_UNUSED = 0;
114 
115  virtual const void *getHash() const A_WARN_UNUSED
116  { return nullptr; }
117 
118  virtual const void *getHash2() const A_WARN_UNUSED
119  { return this; }
120 
121  virtual bool updateNumber(const unsigned num) = 0;
122 
123  protected:
124  Sprite() :
125  mAlpha()
126  {
127  }
128 
129  float mAlpha;
130 };
131 
132 #endif // RESOURCES_SPRITE_SPRITE_H
#define A_DELETE_COPY(func)
Definition: localconsts.h:52
virtual bool update(const int time)=0
virtual const void * getHash2() const
Definition: sprite.h:118
virtual bool updateNumber(const unsigned num)=0
virtual unsigned int getFrameCount() const =0
Sprite()
Definition: sprite.h:124
Definition: sprite.h:32
virtual const void * getHash() const
Definition: sprite.h:115
#define A_WARN_UNUSED
Definition: localconsts.h:172
virtual bool setSpriteDirection(const SpriteDirection::Type direction)=0
virtual float getAlpha() const
Definition: sprite.h:102
#define A_NONNULL(...)
Definition: localconsts.h:179
virtual int getHeight() const =0
#define notfinal
Definition: localconsts.h:289
virtual int getWidth() const =0
virtual unsigned int getCurrentFrame() const =0
Definition: image.h:61
virtual void setAlpha(float alpha)
Definition: sprite.h:96
float mAlpha
Definition: sprite.h:129
virtual const Image * getImage() const =0
virtual bool play(const std::string &action)=0
virtual void draw(Graphics *const graphics, const int posX, const int posY) const =0
virtual bool reset()=0