ManaPlus
Public Member Functions | Protected Member Functions | Protected Attributes
Sprite Class Referenceabstract

#include <sprite.h>

Inheritance diagram for Sprite:
AnimatedSprite CompoundSprite ImageSprite ActorSprite Being FloorItem LocalPlayer

Public Member Functions

virtual ~Sprite ()
 
virtual bool reset ()=0
 
virtual bool play (const std::string &action)=0
 
virtual bool update (const int time)=0
 
virtual void draw (Graphics *const graphics, const int posX, const int posY) const =0
 
virtual int getWidth () const =0
 
virtual int getHeight () const =0
 
virtual const ImagegetImage () const =0
 
virtual bool setSpriteDirection (const SpriteDirection::Type direction)=0
 
virtual void setAlpha (float alpha)
 
virtual float getAlpha () const
 
virtual unsigned int getCurrentFrame () const =0
 
virtual unsigned int getFrameCount () const =0
 
virtual const void * getHash () const
 
virtual const void * getHash2 () const
 
virtual bool updateNumber (const unsigned num)=0
 

Protected Member Functions

 Sprite ()
 

Protected Attributes

float mAlpha
 

Detailed Description

Definition at line 33 of file sprite.h.

Constructor & Destructor Documentation

◆ ~Sprite()

virtual Sprite::~Sprite ( )
inlinevirtual

Definition at line 38 of file sprite.h.

39  { }

◆ Sprite()

Sprite::Sprite ( )
inlineprotected

Definition at line 125 of file sprite.h.

125  :
126  mAlpha()
127  {
128  }
float mAlpha
Definition: sprite.h:130

Member Function Documentation

◆ draw()

virtual void Sprite::draw ( Graphics *const  graphics,
const int  posX,
const int  posY 
) const
pure virtual

Draw the current animation frame at the coordinates given in screen pixels.

Implemented in ImageSprite, AnimatedSprite, FloorItem, and Being.

◆ getAlpha()

virtual float Sprite::getAlpha ( ) const
inlinevirtual

Returns the current alpha opacity of the animated sprite.

Reimplemented in ActorSprite.

Definition at line 103 of file sprite.h.

104  { return mAlpha; }

References mAlpha.

Referenced by ActorSprite::getAlpha().

◆ getCurrentFrame()

virtual unsigned int Sprite::getCurrentFrame ( ) const
pure virtual

Returns the current frame number for the sprite.

Implemented in ImageSprite, AnimatedSprite, and CompoundSprite.

◆ getFrameCount()

virtual unsigned int Sprite::getFrameCount ( ) const
pure virtual

Returns the frame count for the sprite.

Implemented in ImageSprite, AnimatedSprite, and CompoundSprite.

◆ getHash()

virtual const void* Sprite::getHash ( ) const
inlinevirtual

Reimplemented in AnimatedSprite.

Definition at line 116 of file sprite.h.

117  { return nullptr; }

◆ getHash2()

virtual const void* Sprite::getHash2 ( ) const
inlinevirtual

Definition at line 119 of file sprite.h.

120  { return this; }

◆ getHeight()

virtual int Sprite::getHeight ( ) const
pure virtual

Gets the height in pixels of the image of the current frame

Implemented in ImageSprite, AnimatedSprite, CompoundSprite, Being, and ActorSprite.

Referenced by NpcDialog::logic(), and NpcDialog::showAvatar().

◆ getImage()

virtual const Image* Sprite::getImage ( ) const
pure virtual

Returns a reference to the current image being drawn.

Implemented in ImageSprite, AnimatedSprite, and CompoundSprite.

◆ getWidth()

virtual int Sprite::getWidth ( ) const
pure virtual

Gets the width in pixels of the image of the current frame

Implemented in ImageSprite, AnimatedSprite, CompoundSprite, Being, and ActorSprite.

Referenced by NpcDialog::logic(), and NpcDialog::showAvatar().

◆ play()

virtual bool Sprite::play ( const std::string &  action)
pure virtual

Plays an action using the current direction.

Returns
true if the sprite changed, false otherwise

Implemented in AnimatedSprite, ImageSprite, and CompoundSprite.

◆ reset()

virtual bool Sprite::reset ( )
pure virtual

Resets the sprite.

Returns
true if the sprite changed, false otherwise

Implemented in ImageSprite, AnimatedSprite, and CompoundSprite.

◆ setAlpha()

virtual void Sprite::setAlpha ( float  alpha)
inlinevirtual

Sets the alpha value of the animated sprite

Reimplemented in AnimatedSprite, CompoundSprite, and ActorSprite.

Definition at line 97 of file sprite.h.

98  { mAlpha = alpha; }

References mAlpha.

◆ setSpriteDirection()

virtual bool Sprite::setSpriteDirection ( const SpriteDirection::Type  direction)
pure virtual

Sets the direction.

Returns
true if the sprite changed, false otherwise

Implemented in ImageSprite, AnimatedSprite, and CompoundSprite.

◆ update()

virtual bool Sprite::update ( const int  time)
pure virtual

Inform the animation of the passed time so that it can output the correct animation frame.

Returns
true if the sprite changed, false otherwise

Implemented in ImageSprite, AnimatedSprite, and CompoundSprite.

◆ updateNumber()

virtual bool Sprite::updateNumber ( const unsigned  num)
pure virtual

Implemented in ImageSprite, AnimatedSprite, and CompoundSprite.

Field Documentation

◆ mAlpha

float Sprite::mAlpha
protected

The documentation for this class was generated from the following file: