ge211  2021.5.1
A student game engine
Sprite_set Class Reference

Detailed Description

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.

See also
Sprite_set::add_sprite(Sprite const&, Posn<int>, int, Transform const&)
class Sprite
class Transform

Definition at line 508 of file ge211_sprites.hxx.

Public Member Functions

Sprite_setadd_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...
 

Member Function Documentation

◆ add_sprite()

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.

Parameters
spriteThe sprite to render in the window.
xyThe (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.
Returns
a reference to this same Sprite_set

Ownership

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.

See also
struct Posn
class Transform
class Sprite

Definition at line 18 of file ge211_sprites.cxx.


The documentation for this class was generated from the following files: