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-2019 The ManaPlus Developers
5  * Copyright (C) 2019-2021 Andrei Karas
6  *
7  * This file is part of The ManaPlus Client.
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #ifndef RESOURCES_SPRITE_SPRITE_H
24 #define RESOURCES_SPRITE_SPRITE_H
25 
27 
28 #include "localconsts.h"
29 
30 class Graphics;
31 class Image;
32 
34 {
35  public:
37 
38  virtual ~Sprite()
39  { }
40 
46  virtual bool reset() = 0;
47 
53  virtual bool play(const std::string &action) = 0;
54 
61  virtual bool update(const int time) = 0;
62 
67  virtual void draw(Graphics *const graphics,
68  const int posX, const int posY)
69  const A_NONNULL(2) = 0;
70 
74  virtual int getWidth() const A_WARN_UNUSED = 0;
75 
79  virtual int getHeight() const A_WARN_UNUSED = 0;
80 
84  virtual const Image* getImage() const A_WARN_UNUSED = 0;
85 
92  direction) = 0;
93 
97  virtual void setAlpha(float alpha)
98  { mAlpha = alpha; }
99 
103  virtual float getAlpha() const A_WARN_UNUSED
104  { return mAlpha; }
105 
109  virtual unsigned int getCurrentFrame() const A_WARN_UNUSED = 0;
110 
114  virtual unsigned int getFrameCount() const A_WARN_UNUSED = 0;
115 
116  virtual const void *getHash() const A_WARN_UNUSED
117  { return nullptr; }
118 
119  virtual const void *getHash2() const A_WARN_UNUSED
120  { return this; }
121 
122  virtual bool updateNumber(const unsigned num) = 0;
123 
124  protected:
125  Sprite() :
126  mAlpha()
127  {
128  }
129 
130  float mAlpha;
131 };
132 
133 #endif // RESOURCES_SPRITE_SPRITE_H
Definition: sprite.h:34
virtual const Image * getImage() const =0
Sprite()
Definition: sprite.h:125
virtual int getHeight() const =0
virtual bool play(const std::string &action)=0
virtual bool update(const int time)=0
virtual int getWidth() const =0
virtual void setAlpha(float alpha)
Definition: sprite.h:97
virtual float getAlpha() const
Definition: sprite.h:103
virtual bool setSpriteDirection(const SpriteDirection::Type direction)=0
float mAlpha
Definition: sprite.h:130
virtual bool updateNumber(const unsigned num)=0
virtual const void * getHash2() const
Definition: sprite.h:119
virtual const void * getHash() const
Definition: sprite.h:116
virtual unsigned int getCurrentFrame() const =0
virtual unsigned int getFrameCount() const =0
virtual void draw(Graphics *const graphics, const int posX, const int posY) const =0
virtual bool reset()=0
#define A_WARN_UNUSED
Definition: localconsts.h:161
#define notfinal
Definition: localconsts.h:261
#define A_NONNULL(...)
Definition: localconsts.h:168
#define A_DELETE_COPY(func)
Definition: localconsts.h:53