A collection of positioned Sprites ready to be rendered to the screen.
Each time Abstract_game::draw(Sprite_set&) is called by the game engine, it is given an empty Sprite_set, and it must add every Sprite that should appear on the screen to that Sprite_set. Each Sprite is added with an x–y coordinates (Posn<int>) and a z coordinate that determines stacking order. Each sprite may have a Transform applied as well.
class
Sprite class
Transform Definition at line 508 of file ge211_sprites.hxx.
Public Member Functions | |
Sprite_set & | add_sprite (Sprite const &sprite, Posn< int > xy, int z=0, Transform const &transform=Transform()) |
Adds the given sprite to the sprite set to render it in the next frame. More... | |
Sprite_set & add_sprite | ( | Sprite const & | sprite, |
Posn< int > | xy, | ||
int | z = 0 , |
||
Transform const & | transform = Transform() |
||
) |
Adds the given sprite to the sprite set to render it in the next frame.
sprite | The sprite to render in the window. |
xy | The (x, y) coordinates of the sprite, given as the position of its top-left corner relative to the top-left corner of the window. |
z | (optional, defaults to 0) The z coordinate, which determines the relative layering of all the sprites in the window. The layering of sprites placed with the same z is unspecified and not related to the order in which they were added, so you may need to specify z if sprites overlap and you care which appears in front. |
transform | (optional, defaults to the identity transform) A Transform allows scaling, flipping, and rotating the Sprite when it is rendered. |
This function borrows the sprite and retains a reference to it in the the Sprite_set, which is then used to render the sprite after Abstract_game::draw(Sprite_set&) returns. This means that any sprites added to the Sprite_set need to be owned by some other object that outlives the current call to Abstract_game::draw.
Definition at line 18 of file ge211_sprites.cxx.