Table of Contents

 
PlaceSprite
 

Purpose

Moves a sprite to a new location

 

Protoype

void CSpriteMngr::PlaceSprite (string str_sprite_id, int i_new_x, int i_new_y, exclude ex_list = exclude(), 
                               int i_flag = LIST_IN)
 

Parameters

sprite_id the ID of the sprite object to place, ALL_SPRITES if placing more than one object
newx the new X position
newy the new Y position
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 places sprite objects at the coordinates given. So if a sprite object is located at (100, 200) and you pass in i_newx and i_newy values of 50 and 50, the new location of the sprite object will be (50, 50). If you want relative movement, then use MoveSprite().

Placing Multiple Objects

If you want to place 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 place all sprite objects except certain ones, pass those in for ex_list along with the flag LIST_IN. If you want to place 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;
// place one sprite object
sprite.PlaceSprite("my_sprite", 50, 50);
// place ALL sprite objects except "my_sprite"
exclude ex_list;
ex_list.push_back("my_sprite");
sprite.PlaceSprite(ALL_SPRITES, 50, 50, ex_list, LIST_IN);
// place 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.PlaceSprite(ALL_SPRITES, 50, 50, ex_list, LIST_OUT);
 

Prev: MoveSprites