Table of Contents

 
ShowSprite
 

Purpose

Shows or hides a sprite, all sprites, or a select number of sprites

 

Protoype

void CSpriteMngr::ShowSprite (bool b_show, string str_sprite_id, exclude ex_list = exclude(), int i_flag = LIST_IN)
 

Parameters

show whether to show (TRUE) or hide (FALSE) the sprite
sprite_id the ID of the sprite to show/hide, ALL_SPRITES if showing/hiding more than one sprite object
list the list of sprite objects to exclude or include in function
flag whether to exclude objects not in the list (LIST_OUT) or objects in the list (LIST_IN)
 

Description

This function controls sprite visibility. If you want to make a sprite visible (rendered on screen) then you would pass TRUE in for b_show. If you want to hide the sprite, then you would pass in FALSE for b_show. If a sprite is hidden, that does not stop its animation (if any) from playing.

Showing/Hiding Multiple Objects

If you want to show/hide more than one sprite object at once, then you can use the last two parameters of the function. First you must compile a list (an STL vector) of objects that you want to either exclude or include. If you want to show/hide all sprite objects except certain ones, pass those in for ex_list along with the flag LIST_IN. If you want to show/hide only a certain set of objects, pass those in for ex_list along with the flag LIST_OUT. You should also pass ALL_SPRITES for str_sprite_id.

 

Use

CSpriteMngr sprite;
// show one sprite object
sprite.ShowSprite(true, "my_sprite");
// hide ALL sprite objects except "my_sprite"
exclude ex_list;
ex_list.push_back("my_sprite");
sprite.ShowSprite(false, ALL_SPRITES, ex_list, LIST_IN);
// show ONLY these three sprite objects
exclude ex_list;
ex_list.push_back("my_sprite1");
ex_list.push_back("my_sprite2");
ex_list.push_back("my_sprite3");
sprite.ShowSprite(true, ALL_SPRITES, ex_list, LIST_OUT);
 

Prev: SetRepeat