39 play(SpriteAction::STAND);
45 auto spriteDef = resman->
getSprite(filename, variant);
48 return new Sprite(spriteDef);
98 play(SpriteAction::STAND);
An action consists of several animations, one for each direction.
Animation * getAnimation(int direction) const
An animation consists of several frames, each with their own delay and offset.
Frame * getFrame(int index)
Returns the frame at the specified index.
static bool isTerminator(const Frame &phase)
Determines whether the given animation frame is a terminator.
int getLength() const
Returns the length of this animation in frames.
int getDuration() const
Returns the duration of this animation in milliseconds.
A central point of control for graphics.
bool drawImage(const Image *image, int x, int y)
Blits an image onto the screen.
Defines a class for loading and storing images.
int getHeight() const
Returns the height of the image.
int getWidth() const
Returns the width of the image.
void setAlpha(float alpha)
Sets the alpha value of this image.
float getAlpha() const
Returns the alpha value of this image.
A class for loading and managing resources.
ResourceRef< SpriteDef > getSprite(const std::string &path, int variant=0)
Loads a SpriteDef based on a given path and the supplied variant.
static ResourceManager * getInstance()
Returns an instance of the class, creating one if it does not already exist.
Defines a class to load an animation.
Action * getAction(const std::string &action) const
Returns the specified action.
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.
Sprite(SpriteDef *sprite)
Constructor.
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.
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.
A single frame in an animation, with a delay and an offset.