17 #ifndef HEADER_SUPERTUX_SPRITE_SPRITE_HPP 18 #define HEADER_SUPERTUX_SPRITE_SPRITE_HPP 20 #include "sprite/sprite_data.hpp" 21 #include "sprite/sprite_ptr.hpp" 22 #include "video/canvas.hpp" 23 #include "video/drawing_context.hpp" 31 SpritePtr clone()
const;
38 void set_action(
const std::string& name,
int loops = -1);
47 void stop_animation() { m_animation_loops = 0; }
53 int get_frames()
const {
return static_cast<int>(m_action->surfaces.size()); }
59 const std::string&
get_name()
const {
return m_data.name; }
62 const std::string&
get_action()
const {
return m_action->name; }
64 int get_width()
const;
65 int get_height()
const;
84 void set_color(
const Color& color);
85 Color get_color()
const;
87 void set_blend(
const Blend& blend);
88 Blend get_blend()
const;
90 bool has_action (
const std::string& name)
const {
return (m_data.get_action(name) !=
nullptr); }
101 int m_animation_loops;
107 const SpriteData::Action* m_action;
Definition: sprite_data.hpp:28
Simple two dimensional vector.
Definition: vector.hpp:24
Definition: sprite.hpp:25
float get_current_hitbox_width() const
return width of current action's hitbox
Definition: sprite.cpp:185
void set_angle(float angle)
Set the angle of the sprite rotation in degree.
Definition: sprite.cpp:203
void draw(Canvas &canvas, const Vector &pos, int layer, Flip flip=NO_FLIP)
Draw sprite, automatically calculates next frame.
Definition: sprite.cpp:136
const std::string & get_name() const
Get sprite's name.
Definition: sprite.hpp:59
int get_current_frame() const
Get currently drawn frame.
Definition: sprite.hpp:56
void set_action_continued(const std::string &name)
Set action (or state), but keep current frame number, loop counter, etc.
Definition: sprite.cpp:85
void set_action(const std::string &name, int loops=-1)
Set action (or state)
Definition: sprite.cpp:65
Rectf get_current_hitbox() const
return current action's hitbox, relative to 0,0
Definition: sprite.cpp:197
bool animation_done() const
Check if animation is stopped or not.
Definition: sprite.cpp:101
float get_current_hitbox_height() const
return height of current action's hitbox
Definition: sprite.cpp:191
void set_animation_loops(int loops=-1)
Set number of animation cycles until animation stops.
Definition: sprite.hpp:44
float get_current_hitbox_x_offset() const
return x-offset of current action's hitbox, relative to start of image
Definition: sprite.cpp:173
const std::string & get_action() const
Get current action name.
Definition: sprite.hpp:62
int get_frames() const
Get current action total frames.
Definition: sprite.hpp:53
float get_current_hitbox_y_offset() const
return y-offset of current action's hitbox, relative to start of image
Definition: sprite.cpp:179
Definition: canvas.hpp:43
float get_angle() const
Get the angle of the sprite rotation in degree.
Definition: sprite.cpp:209