CF_Sprite¶
Category: sprite
GitHub: cute_sprite.h
A sprite represents a drawable entity, made of 2D animations/images.
| Struct Members | Description |
|---|---|
uint64_t id |
For internal use -- Unique sprite id |
const char* name |
The name of the sprite. |
int w |
Width of the sprite in pixels. |
int h |
Height of the sprite in pixels. |
uint64_t _image_id |
For internal use -- Cached image ID of the current frame (set by cf_sprite_update / cf_sprite_play). |
CF_V2 _pivot |
For internal use -- Cached pivot of the current frame (set by cf_sprite_update / cf_sprite_play). |
CF_Aabb _center_patch |
For internal use -- Cached center patch of the current frame for 9-slice (set by cf_sprite_update / cf_sprite_play). |
CF_V2 scale |
Scale factor for the sprite when drawing. Default of (1, 1). See cf_draw_sprite. |
CF_V2 offset |
A local offset/origin for the sprite when drawing. Defaults to (0, 0). |
float opacity |
An opacity value for the entire sprite. Default of 1.0f. See cf_draw_sprite. |
int frame_index |
The current frame within animation to display. |
int loop_count |
The number of times this sprite has completed an animation. |
float play_speed_multiplier |
A speed multiplier for updating frames. Default of 1.0f. |
bool paused |
Whether or not to pause updates to the animation. |
bool loop |
Whether or not to loop animations. |
bool finished |
Set to true when a non-looping animation reaches its last frame. Only meaningful when loop is false. Reset to false by cf_sprite_play. |
float t |
The current elapsed time within a frame of animation. |
uint64_t easy_sprite_id |
For internal use only. |
CF_PlayDirection play_direction |
Controls the animation play direction. This gets set each time cf_sprite_play is called to the animation's play direction. You may override this member yourself after calling cf_sprite_play. |
int blend_index |
Which blend to draw. 0 = default (all visible layers). Use cf_sprite_add_blend to register additional blends. |
const char* animation_name |
Interned name of the current animation. |
CF_Transform transform |
An optional transform for rendering within a particular space. See CF_Transform. |
Remarks¶
Sprites can be drawn by cf_draw_sprite. Since sprites are plain old data POD you may create one on the stack anywhere
and freely copy it around. In C++ you may simply draw via sprite.draw().
Related Pages¶
CF_Frame
CF_Animation
cf_make_sprite
cf_make_easy_sprite