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 32 of file sprite.h.

Constructor & Destructor Documentation

◆ ~Sprite()

virtual Sprite::~Sprite ( )
inlinevirtual

◆ Sprite()

Sprite::Sprite ( )
inlineprotected

Definition at line 124 of file sprite.h.

124  :
125  mAlpha()
126  {
127  }
float mAlpha
Definition: sprite.h:129

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 Being, FloorItem, AnimatedSprite, and ImageSprite.

Referenced by ~Sprite().

◆ getAlpha()

virtual float Sprite::getAlpha ( ) const
inlinevirtual

Returns the current alpha opacity of the animated sprite.

Reimplemented in ActorSprite.

Definition at line 102 of file sprite.h.

References getCurrentFrame(), getFrameCount(), and mAlpha.

Referenced by ActorSprite::getAlpha().

103  { return mAlpha; }
float mAlpha
Definition: sprite.h:129

◆ getCurrentFrame()

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

Returns the current frame number for the sprite.

Implemented in AnimatedSprite, CompoundSprite, and ImageSprite.

Referenced by getAlpha().

◆ getFrameCount()

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

Returns the frame count for the sprite.

Implemented in AnimatedSprite, CompoundSprite, and ImageSprite.

Referenced by getAlpha().

◆ getHash()

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

Reimplemented in AnimatedSprite.

Definition at line 115 of file sprite.h.

116  { return nullptr; }

◆ getHash2()

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

Definition at line 118 of file sprite.h.

References updateNumber().

119  { return this; }

◆ getHeight()

virtual int Sprite::getHeight ( ) const
pure virtual

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

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

Referenced by CompoundSprite::getHeight(), NpcDialog::logic(), NpcDialog::showAvatar(), and ~Sprite().

◆ getImage()

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

Returns a reference to the current image being drawn.

Implemented in AnimatedSprite, CompoundSprite, and ImageSprite.

Referenced by ~Sprite().

◆ getWidth()

virtual int Sprite::getWidth ( ) const
pure virtual

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

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

Referenced by CompoundSprite::getWidth(), NpcDialog::logic(), NpcDialog::showAvatar(), and ~Sprite().

◆ 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, CompoundSprite, and ImageSprite.

Referenced by ~Sprite().

◆ reset()

virtual bool Sprite::reset ( )
pure virtual

Resets the sprite.

Returns
true if the sprite changed, false otherwise

Implemented in AnimatedSprite, CompoundSprite, and ImageSprite.

Referenced by ~Sprite().

◆ setAlpha()

virtual void Sprite::setAlpha ( float  alpha)
inlinevirtual

Sets the alpha value of the animated sprite

Reimplemented in ActorSprite, AnimatedSprite, and CompoundSprite.

Definition at line 96 of file sprite.h.

References mAlpha.

97  { mAlpha = alpha; }
float mAlpha
Definition: sprite.h:129

◆ setSpriteDirection()

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

Sets the direction.

Returns
true if the sprite changed, false otherwise

Implemented in AnimatedSprite, CompoundSprite, and ImageSprite.

Referenced by ~Sprite().

◆ 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 AnimatedSprite, CompoundSprite, and ImageSprite.

Referenced by ~Sprite().

◆ updateNumber()

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

Implemented in AnimatedSprite, CompoundSprite, and ImageSprite.

Referenced by getHash2().

Field Documentation

◆ mAlpha

float Sprite::mAlpha
protected

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