Download Tutorial C Files H Files

dg_sys_animator

This function is used to create an animator system.

Usage

void dg_sys_animator(dg_entity_t *entity, dg_window_t *w, dg_array_t **entities, sfTime dt);

Example

dg_scene_add_sys(v->scene_game, dg_system_create(&dg_sys_animator));

Source code

void dg_sys_animator(dg_entity_t *entity, dg_window_t *w,
    dg_array_t **entities, sfTime dt)
{
    dg_animator_t *animator = (dg_animator_t *)
        (dg_entity_get_component(entity, "animator"));
    sfSprite *sprite = (sfSprite *)(dg_entity_get_component(entity, "sprite"));

    if (!dg_system_require(entity, 2, "animator", "sprite"))
        return;
    dg_animator_update_sprite(animator, sprite, dt.microseconds);
}