Download Tutorial C Files H Files

dg_animator_update_sprite

This function is used to add an animation to the animator.

Usage

void dg_animator_update_sprite(dg_animator_t *animator, sfSprite *sprite, int time);

Example

dg_animator_update_sprite(animator, sprite, dt);

Source code

void dg_animator_update_sprite(dg_animator_t *animator, sfSprite *sprite, int time)
{
    if (animator && animator->length > animator->current) {
        dg_animation_t *animation = animator->animations[animator->current];
        dg_spritesheet_t *sheet = animation->sheet;
        int frame = animation->frames[(int)(time % animation->size)];
        dg_spritesheet_to_sprite(sheet, sprite, frame);
    }
}