VgaGames4

VgaGames4 - sprite man-pages

[.. upper level ..]

# vg4->sprite->next()

Set sprite to next element, returning next image with attributes and playing sound.

SYNTAX
VG_BOOL vg4->sprite->next(struct VG_Sprite *sprt, struct VG_Image **imgp, struct VG_ImagecopyAttr *iattr)
FUNCTION PARAMETERS

sprt | Sprite
imgp | For returning image; it may return NULL if the element has no image
iattr | For returning image's image-copy attributes

RETURN VALUE
Returns boolean: - VG_TRUE: OK - VG_FALSE: Sprite ended
DESCRIPTION
Set sprite to next element. If the next element (or the next repetition of the current element) has an image, it will be returned in imgp with its attributes in iattr. imgp will return NULL if there is no image defined. imgp and iattr may be passed as NULL, if they are not needed. If the next element defines playing a sound, it will be played. In a repetition the sound will be played just once at the beginning. If the sprite ended (header value LIFETIME is greater 0) the returned value is VG_FALSE.
EXAMPLE

    /* load a sprite and show it on the window until it ends */

    struct VG_Sprite *sprt;
    struct VG_Image *imgp;
    struct VG_ImagecopyAttr iattr;

    /* load sprite, assuming no error */
    sprt = vg4->sprite->load("my.sprite");

    for (;;) {
      /* get next sprite-element, check for ending sprite */
      if (!vg4->sprite->next(sprt, &imgp, &iattr)) { break; }

      /* copy image to window, if an image was returned */
      vg4->window->clear();
      if (imgp != NULL) {
        vg4->window->copy(imgp, NULL, &iattr);
      }

      vg4->window->flush();
      vg4->misc->wait_time(50);
    }

SEE ALSO
vg4->sprite->has_next() vg4->sprite->current() vg4->sprite->rewind()