52 static Sprite *
load(
const std::string &filename,
int variant = 0);
68 bool play(
const std::string &action);
An action consists of several animations, one for each direction.
An animation consists of several frames, each with their own delay and offset.
A central point of control for graphics.
Defines a class for loading and storing images.
Automatically counting Resource reference.
Defines a class to load an animation.
Animates a sprite by adding playback state.
int getOffsetY() const
Gets the vertical offset that the sprite will be drawn at.
int getDuration() const
Returns the duration of the current sprite animation in milliseconds.
int mFrameIndex
The index of the current frame.
int mFrameTime
The time since start of frame.
float getAlpha() const
Returns the current alpha opacity of the sprite.
bool draw(Graphics *graphics, int posX, int posY) const
Draw the current animation frame at the coordinates given in screen pixels.
Animation * mAnimation
The currently active animation.
bool updateCurrentAnimation(int dt)
int getWidth() const
Gets the width in pixels of the image.
SpriteDirection mDirection
The sprite direction.
bool update(int time)
Inform the animation of the passed time so that it can output the correct animation frame.
Action * mAction
The currently active action.
const Image * getImage() const
Returns a reference to the current image being drawn.
static Sprite * load(const std::string &filename, int variant=0)
An helper function, which will request the sprite to animate from the resource manager.
float mAlpha
The alpha opacity used to draw.
int getOffsetX() const
Gets the horizontal offset that the sprite will be drawn at.
bool setDirection(SpriteDirection direction)
Sets the direction.
ResourceRef< SpriteDef > mSprite
The sprite definition.
Frame * mFrame
The currently active frame.
void setAlpha(float alpha)
Sets the alpha value of the sprite.
bool reset()
Resets the sprite.
int getHeight() const
Gets the height in pixels of the image.
bool play(const std::string &action)
Plays an action using the current direction.
const int DEFAULT_FRAME_DELAY
A single frame in an animation, with a delay and an offset.