class
#include <bn_sprite_tiles_ptr.h>
sprite_tiles_ptr std::shared_ptr like smart pointer that retains shared ownership of the tiles of a sprite.
Several sprite_
The sprite tiles are released when the last remaining sprite_
The tiles are not copied but referenced, so they should outlive the sprite_
Public static functions
-
static auto find(const sprite_
tiles_ item& tiles_item) -> optional<sprite_ tiles_ ptr> - Searches for a sprite_
tiles_ ptr which references the given tiles. -
static auto find(const sprite_
tiles_ item& tiles_item, int graphics_index) -> optional<sprite_ tiles_ ptr> - Searches for a sprite_
tiles_ ptr which references the given tiles. -
static auto create(const sprite_
tiles_ item& tiles_item) -> sprite_ tiles_ ptr - Searches for a sprite_
tiles_ ptr which references the given tiles. If it is not found, it creates a sprite_ tiles_ ptr which references them. -
static auto create(const sprite_
tiles_ item& tiles_item, int graphics_index) -> sprite_ tiles_ ptr - Searches for a sprite_
tiles_ ptr which references the given tiles. If it is not found, it creates a sprite_ tiles_ ptr which references them. -
static auto allocate(int tiles_count,
bpp_
mode bpp) -> sprite_ tiles_ ptr - Creates a sprite_
tiles_ ptr which references a chunk of VRAM tiles not visible on the screen. -
static auto create_optional(const sprite_
tiles_ item& tiles_item) -> optional<sprite_ tiles_ ptr> - Searches for a sprite_
tiles_ ptr which references the given tiles. If it is not found, it creates a sprite_ tiles_ ptr which references them. -
static auto create_optional(const sprite_
tiles_ item& tiles_item, int graphics_index) -> optional<sprite_ tiles_ ptr> - Searches for a sprite_
tiles_ ptr which references the given tiles. If it is not found, it creates a sprite_ tiles_ ptr which references them. -
static auto allocate_optional(int tiles_count,
bpp_
mode bpp) -> optional<sprite_ tiles_ ptr> - Creates a sprite_
tiles_ ptr which references a chunk of VRAM tiles not visible on the screen.
Constructors, destructors, conversion operators
-
sprite_tiles_ptr(const sprite_
tiles_ ptr& other) - Copy constructor.
-
sprite_tiles_ptr(sprite_
tiles_ ptr&& other) noexcept - Move constructor.
- ~sprite_tiles_ptr()
- Releases the referenced sprite tiles if no more sprite_
tiles_ ptr objects reference to them.
Public functions
-
auto operator=(const sprite_
tiles_ ptr& other) -> sprite_ tiles_ ptr& - Copy assignment operator.
-
auto operator=(sprite_
tiles_ ptr&& other) -> sprite_ tiles_ ptr& noexcept - Move assignment operator.
- auto id() const -> int
- Returns the internal id.
- auto tiles_count() const -> int
- Returns the referenced number of tiles.
-
auto compression() const -> compression_
type - Returns the compression of the referenced tiles.
- auto tiles_ref() const -> optional<span<const tile>>
- Returns the referenced tiles unless it was created with allocate or allocate_optional. In that case, it returns bn::
nullopt. -
void set_tiles_ref(const sprite_
tiles_ item& tiles_item) - Sets the tiles to handle.
-
void set_tiles_ref(const sprite_
tiles_ item& tiles_item, int graphics_index) - Sets the tiles to handle.
- void reload_tiles_ref()
- Uploads the referenced tiles to VRAM again to make visible the possible changes in them.
- auto vram() -> optional<span<tile>>
- Returns the allocated memory in VRAM if this sprite_
tiles_ ptr was created with allocate or allocate_optional; bn:: nullopt otherwise. - auto handle() const -> int
- Returns the internal handle.
-
void swap(sprite_
tiles_ ptr& other) - Exchanges the contents of this sprite_
tiles_ ptr with those of the other one.
Friends
-
void swap(sprite_
tiles_ ptr& a, sprite_ tiles_ ptr& b) - Exchanges the contents of a sprite_
tiles_ ptr with those of another one. -
auto operator==(const sprite_
tiles_ ptr& a, const sprite_ tiles_ ptr& b) -> bool defaulted - Default equal operator.
Function documentation
static optional<sprite_ tiles_ ptr> bn:: sprite_tiles_ptr:: find(const sprite_ tiles_ item& tiles_item)
Searches for a sprite_
Parameters | |
---|---|
tiles_item | sprite_ |
Returns | sprite_ |
static optional<sprite_ tiles_ ptr> bn:: sprite_tiles_ptr:: find(const sprite_ tiles_ item& tiles_item,
int graphics_index)
Searches for a sprite_
Parameters | |
---|---|
tiles_item | sprite_ |
graphics_index | Index of the tile set to search in sprite_ |
Returns | sprite_ |
static sprite_ tiles_ ptr bn:: sprite_tiles_ptr:: create(const sprite_ tiles_ item& tiles_item)
Searches for a sprite_
Parameters | |
---|---|
tiles_item | sprite_ |
Returns | sprite_ |
The tiles are not copied but referenced, so they should outlive the sprite_
static sprite_ tiles_ ptr bn:: sprite_tiles_ptr:: create(const sprite_ tiles_ item& tiles_item,
int graphics_index)
Searches for a sprite_
Parameters | |
---|---|
tiles_item | sprite_ |
graphics_index | Index of the tile set to search in sprite_ |
Returns | sprite_ |
The tiles are not copied but referenced, so they should outlive the sprite_
static sprite_ tiles_ ptr bn:: sprite_tiles_ptr:: allocate(int tiles_count,
bpp_ mode bpp)
Creates a sprite_
Parameters | |
---|---|
tiles_count | Number of tiles to allocate. |
bpp | Bits per pixel of the tiles to allocate. |
Returns | sprite_ |
static optional<sprite_ tiles_ ptr> bn:: sprite_tiles_ptr:: create_optional(const sprite_ tiles_ item& tiles_item)
Searches for a sprite_
Parameters | |
---|---|
tiles_item | sprite_ |
Returns | sprite_ |
The tiles are not copied but referenced, so they should outlive the sprite_
static optional<sprite_ tiles_ ptr> bn:: sprite_tiles_ptr:: create_optional(const sprite_ tiles_ item& tiles_item,
int graphics_index)
Searches for a sprite_
Parameters | |
---|---|
tiles_item | sprite_ |
graphics_index | Index of the tile set to search in sprite_ |
Returns | sprite_ |
The tiles are not copied but referenced, so they should outlive the sprite_
static optional<sprite_ tiles_ ptr> bn:: sprite_tiles_ptr:: allocate_optional(int tiles_count,
bpp_ mode bpp)
Creates a sprite_
Parameters | |
---|---|
tiles_count | Number of tiles to allocate. |
bpp | Bits per pixel of the tiles to allocate. |
Returns | sprite_ |
bn:: sprite_tiles_ptr:: sprite_tiles_ptr(const sprite_ tiles_ ptr& other)
Copy constructor.
Parameters | |
---|---|
other | sprite_ |
bn:: sprite_tiles_ptr:: sprite_tiles_ptr(sprite_ tiles_ ptr&& other) noexcept
Move constructor.
Parameters | |
---|---|
other | sprite_ |
sprite_ tiles_ ptr& bn:: sprite_tiles_ptr:: operator=(const sprite_ tiles_ ptr& other)
Copy assignment operator.
Parameters | |
---|---|
other | sprite_ |
Returns | Reference to this. |
sprite_ tiles_ ptr& bn:: sprite_tiles_ptr:: operator=(sprite_ tiles_ ptr&& other) noexcept
Move assignment operator.
Parameters | |
---|---|
other | sprite_ |
Returns | Reference to this. |
void bn:: sprite_tiles_ptr:: set_tiles_ref(const sprite_ tiles_ item& tiles_item)
Sets the tiles to handle.
Parameters | |
---|---|
tiles_item | sprite_ |
Remember that the sprite tiles system does not support multiple sprite_
Remember also that the tiles are not copied but referenced, so they should outlive the sprite_
void bn:: sprite_tiles_ptr:: set_tiles_ref(const sprite_ tiles_ item& tiles_item,
int graphics_index)
Sets the tiles to handle.
Parameters | |
---|---|
tiles_item | sprite_ |
graphics_index | Index of the tile set to reference in sprite_ |
Remember that the sprite tiles system does not support multiple sprite_
Remember also that the tiles are not copied but referenced, so they should outlive the sprite_
void bn:: sprite_tiles_ptr:: swap(sprite_ tiles_ ptr& other)
Exchanges the contents of this sprite_
Parameters | |
---|---|
other | sprite_ |
void swap(sprite_ tiles_ ptr& a,
sprite_ tiles_ ptr& b)
Exchanges the contents of a sprite_
Parameters | |
---|---|
a | First sprite_ |
b | Second sprite_ |