Skip to content
Steven Arnow edited this page May 29, 2013 · 11 revisions

DARNIT_SPRITE

A DARNIT_SPRITE is an animated sprite with selectable banks "directions". DARNIT_SPRITE is currently also the only drawable in libDarnit that can be rotated.

  • DARNIT_SPRITE *d_sprite_new(DARNIT_TILESHEET *tilesheet);
  • DARNIT_SPRITE *d_sprite_load(const char *fname, int dir, DARNIT_PFORMAT target_format);
  • DARNIT_SPRITE *d_sprite_free(DARNIT_SPRITE *sprite);
  • void d_sprite_direction_set(DARNIT_SPRITE *sprite, int dir);
  • void d_sprite_activate(DARNIT_SPRITE *sprite, int dir);
  • void d_sprite_frame_set(DARNIT_SPRITE *sprite, int frame);
  • void d_sprite_move(DARNIT_SPRITE *sprite, int x, int y);
  • void d_sprite_rotate(DARNIT_SPRITE *sprite, int angle);
  • void d_sprite_animate_start(DARNIT_SPRITE *sprite);
  • void d_sprite_animate_pause(DARNIT_SPRITE *sprite);
  • void d_sprite_animate_stop(DARNIT_SPRITE *sprite);
  • void d_sprite_animate_repeat(DARNIT_SPRITE *sprite, int repeat);
  • void d_sprite_draw(DARNIT_SPRITE *sprite);
  • void d_sprite_frame_entry(DARNIT_SPRITE *sprite, int dir, int frame, int tile, int time);
  • int d_sprite_width(DARNIT_SPRITE *sprite);
  • int d_sprite_height(DARNIT_SPRITE *sprite);

d_sprite_new

DARNIT_SPRITE *d_sprite_new(DARNIT_TILESHEET *tilesheet);

Creates a new sprite without any frames. Use d_sprite_frame_entry to populate the sprite.

Arguments

Return value

Returns NULL on failure, everything else is a valid DARNIT_SPRITE.

d_sprite_load

DARNIT_SPRITE *d_sprite_load(const char *fname, int dir, DARNIT_PFORMAT target_format);

Loads a sprite from file. See file formats: sprite for help on how to make sprite files.

Arguments

  • fname - The filename of the sprite to load
  • dir - What sprite index "direction" to initialize it to
  • target_format - If the tilesheet needed by the sprite isn't loaded, load it with this pixel format

Return value

Returns NULL on failure, anything else is a valid DARNIT_SPRITE.

d_sprite_free

DARNIT_SPRITE *d_sprite_free(DARNIT_SPRITE *sprite);

Free's a sprite, and if it also loaded a tilesheet, it tries to unload it as well.

Arguments

  • sprite - The sprite to unload

Return value

Returns NULL for compact pointer clearing.

Clone this wiki locally