Skip to content

add and set animation

Fosowl edited this page May 30, 2020 · 4 revisions

add, set and destroy animation the easy way.

create a new animation

This function is use to add a new animation to an entities, use this before adding animation key

void starset_add_animation(entities_t *entities, char *e_name, char *a_name , sfVector2u size);

parameter :

entities_t *entities : the entities chain list that contain all the entities on the scene.

char *e_name : the name of the entities you want to add an animation to.

char *a_name : the name you want to give to your new animation.

sfVector2u size : the size of the rect for each animation frame.

add animation key

this function is use to add a new animation keyframe to an existing animation

void starset_add_animation_key(entities_t *entities, char *e_name , char *a_name, sfVector2f keyframe);

parameter :

entities_t *entities : the entities chain list that contain all the entities on the scene.

char *e_name : the name of the entities you want to add an animation to.

char *a_name : the name you want to give to your new animation.

sfVector2f keyframe : the position of the new keyframe on the spritesheet.

play an animation

this function is use to play an animation

int starset_play_animation(entities_t *entitie, char *e_name , char *a_name, int fps);

parameter

entities_t *entities : the entities chain list that contain all the entities on the scene.

char *e_name : the name of the entities you want to add an animation to.

char *a_name : the name you want to give to your new animation.

int fps : the animation speed in animation key per second (putting 3 mean it will switch to the next animation 3 time in 1 second).

here is an usefull website to help you find animation key size and position :

Sprite cow

Clone this wiki locally