clan::Sprite Class Reference

Sprite class. More...

#include <sprite.h>

Public Types

Enums
enum  ShowOnFinish { show_blank, show_last_frame, show_first_frame }
 

Public Member Functions

Construction
 Sprite ()
 Constructs a null instance. More...
 
 Sprite (Canvas &canvas, const std::string &fullname, const ImageImportDescription &import_desc=ImageImportDescription())
 Constructs a Sprite. More...
 
 Sprite (Canvas &canvas, const std::string &filename, const FileSystem &file_system, const ImageImportDescription &import_desc=ImageImportDescription())
 Constructs a Sprite. More...
 
 Sprite (Canvas &canvas, IODevice &file, const std::string &image_type, const ImageImportDescription &import_desc=ImageImportDescription())
 Constructs a Sprite. More...
 
 Sprite (Canvas &canvas)
 Constructs an empty Sprite. More...
 
virtual ~Sprite ()
 
Attributes
bool is_null () const
 Returns true if this object is invalid. More...
 
void throw_if_null () const
 Throw an exception if this object is invalid. More...
 
Angle get_angle () const
 Returns current angle in degrees. More...
 
Angle get_base_angle () const
 Returns the base angle in degrees - angle added to any rotation set with set_rotate() or rotate(). More...
 
void get_scale (float &x, float &y) const
 Returns scale for x and y. More...
 
float get_alpha () const
 Returns current alpha. More...
 
Colorf get_color () const
 Returns current color. More...
 
bool get_linear_filter () const
 Returns true if the sprite uses a linear filter for scaling up and down, false if a nearest-point filter is used. More...
 
void get_alignment (Origin &origin, int &x, int &y) const
 Returns translation hot-spot. More...
 
void get_rotation_hotspot (Origin &origin, int &x, int &y) const
 Returns rotation hot-spot. More...
 
int get_current_frame () const
 Returns current frame in animation. 0 is first frame. More...
 
int get_frame_count () const
 Returns number of frames in animation. More...
 
int get_frame_delay (int frame) const
 Returns the delay of a frame. More...
 
Point get_frame_offset (int frame) const
 Returns the translation offset of a frame. 0 is first frame. More...
 
Size get_frame_size (int frame) const
 Returns the size of a frame. 0 is first frame. More...
 
Subtexture get_frame_texture (int frame) const
 Return the texture of a frame. 0 is first frame. More...
 
int get_width () const
 Return the width of the current frame, shortcut for 'get_frame_size(get_current_frame()).width'. More...
 
int get_height () const
 Return the height of the current frame, shortcut for 'get_frame_size(get_current_frame()).height'. More...
 
Size get_size () const
 Return the size of the current frame, shortcut for 'get_frame_size(get_current_frame())'. More...
 
int get_id () const
 Returns the attached id (if exists). More...
 
bool is_play_loop () const
 Returns true if animation is played in loop (more than once). More...
 
bool is_play_backward () const
 Returns true if animation is played in from right to left (starts at end). More...
 
bool is_play_pingpong () const
 Returns true if animation is played in ping-pong mode. More...
 
ShowOnFinish get_show_on_finish () const
 Returns an enum for what is shown when the animation is finished. More...
 
bool is_finished () const
 Returns true if animation is finished. More...
 
bool is_looping () const
 Returns true if animation has looped in the last update cycle. More...
 
Operators
bool operator== (const Sprite &other) const
 Equality operator. More...
 
bool operator!= (const Sprite &other) const
 Inequality operator. More...
 
bool operator< (const Sprite &other) const
 Less than operator. More...
 
Operations
Spriteoperator= (const Sprite &copy)
 Copy assignment operator. More...
 
void set_image_data (const Sprite &image_source)
 Sets the image data from another sprite, sharing animation state. More...
 
Sprite clone () const
 Copies all information from this sprite to another, excluding the graphics that remain shared. More...
 
void draw (Canvas &canvas, float x, float y)
 Draw sprite on graphic context. More...
 
void draw (Canvas &canvas, int x, int y)
 
void draw (Canvas &canvas, const Rectf &src, const Rectf &dest)
 
void draw (Canvas &canvas, const Rectf &dest)
 
void update (int time_elapsed_ms)
 Call this function to update the animation. More...
 
void set_angle (Angle angle)
 Set absolute rotation angle. More...
 
void set_angle_pitch (Angle angle)
 Set absolute rotation pitch angle. More...
 
void set_angle_yaw (Angle angle)
 Set absolute rotation yaw angle. More...
 
void rotate (Angle angle)
 Add angle in degrees to current angle. More...
 
void rotate_pitch (Angle angle)
 Add angle in degrees to current pitch angle. More...
 
void rotate_yaw (Angle angle)
 Add angle in degrees to current yaw angle. More...
 
void set_base_angle (Angle angle)
 Sets the base angle in degrees - angle added to any rotation set with set_rotate() or rotate(). More...
 
void set_scale (float x, float y)
 Set scale for x and y directions individually. More...
 
void set_alpha (float alpha)
 Sets transparency. More...
 
void set_color (const Colorf &color)
 Sets the color. More...
 
void set_color (const Color &c)
 Set color. More...
 
void set_linear_filter (bool linear_filter=true)
 Set to true if a linear filter should be used for scaling up and down, false if a nearest-point filter should be used. More...
 
void set_alignment (Origin origin, int x=0, int y=0)
 Sets translation hotspot. More...
 
void set_rotation_hotspot (Origin origin, int x=0, int y=0)
 Sets rotation hotspot. More...
 
void set_frame (unsigned int frame)
 Sets current animation frame. 0 is first frame. More...
 
void set_delay (int delay_ms)
 Sets the delay for all frames. More...
 
void set_frame_delay (int frame, int delay_ms)
 Sets the delay of a specific frame. More...
 
void set_frame_offset (int frame, Point offset)
 Sets the translate offset of a specific frame. 0 is first frame. More...
 
void set_id (int id)
 Sets an attached id. More...
 
void finish ()
 Finish animation. More...
 
void restart ()
 Restart animation. More...
 
void set_play_loop (bool loop=true)
 Set to true if animation should loop, false otherwise. More...
 
void set_play_pingpong (bool pingpong=true)
 Set to true if animation should loop, false otherwise. More...
 
void set_play_backward (bool backward=true)
 Set to true if animation should go backward (start at end). More...
 
void set_show_on_finish (Sprite::ShowOnFinish show_on_finish)
 Set what is shown when the animation is finished. More...
 
void add_frame (const Texture2D &texture)
 Add frame. More...
 
void add_frame (Canvas &canvas, const std::string &fullname, const ImageImportDescription &import_desc=ImageImportDescription())
 Add frame. More...
 
void add_frame (Canvas &canvas, IODevice &file, const std::string &image_type, const ImageImportDescription &import_desc=ImageImportDescription())
 Add frame. More...
 
void add_frame (Canvas &canvas, const std::string &filename, const FileSystem &file_system, const ImageImportDescription &import_desc=ImageImportDescription())
 Add frame. More...
 
void add_frames (const Texture2D &texture, Rect *frames, int num_frames)
 Add frames. More...
 
void add_frame (const Texture2D &texture, const Rect &frame)
 Add frame. More...
 
void add_gridclipped_frames (Canvas &canvas, const Texture2D &texture, int xpos, int ypos, int width, int height, int xarray=1, int yarray=1, int array_skipframes=0, int xspacing=0, int yspacing=0)
 Adds images formed in a grid. More...
 
void add_alphaclipped_frames (Canvas &canvas, const Texture2D &texture, int xpos=0, int ypos=0, float trans_limit=0.05f)
 Adds images separated with pure alpha (within trans_limit). More...
 
void add_alphaclipped_frames_free (Canvas &canvas, const Texture2D &texture, int xpos=0, int ypos=0, float trans_limit=0.05f)
 Adds images separated with pure alpha (within trans_limit). More...
 
Signals
Signal< void()> & sig_animation_finished ()
 Sig animation finished. More...
 

Static Public Member Functions

Resources
static Resource< Spriteresource (Canvas &canvas, const std::string &id, const ResourceManager &resources)
 Retrieves a Sprite resource from the resource manager. More...
 
static Sprite load (Canvas &canvas, const std::string &id, const XMLResourceDocument &doc)
 Loads a Sprite from a XML resource definition. More...
 

Implementation

class FontFamily_Impl
 

Detailed Description

Sprite class.


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