bn::sprite_ptr class

std::shared_ptr like smart pointer that retains shared ownership of a sprite.

Several sprite_ptr objects may own the same sprite.

The sprite is released when the last remaining sprite_ptr owning it is destroyed.

Public static functions

static auto create(const sprite_item& item) -> sprite_ptr
Creates a sprite_ptr from the given sprite_item.
static auto create(const sprite_item& item, int graphics_index) -> sprite_ptr
Creates a sprite_ptr from the given sprite_item.
static auto create(const sprite_shape_size& shape_size, sprite_tiles_ptr tiles, sprite_palette_ptr palette) -> sprite_ptr
Creates a sprite_ptr.
static auto create(fixed x, fixed y, const sprite_item& item) -> sprite_ptr
Creates a sprite_ptr from the given sprite_item.
static auto create(fixed x, fixed y, const sprite_item& item, int graphics_index) -> sprite_ptr
Creates a sprite_ptr from the given sprite_item.
static auto create(const fixed_point& position, const sprite_item& item) -> sprite_ptr
Creates a sprite_ptr from the given sprite_item.
static auto create(const fixed_point& position, const sprite_item& item, int graphics_index) -> sprite_ptr
Creates a sprite_ptr from the given sprite_item.
static auto create(fixed x, fixed y, const sprite_shape_size& shape_size, sprite_tiles_ptr tiles, sprite_palette_ptr palette) -> sprite_ptr
Creates a sprite_ptr.
static auto create(const fixed_point& position, const sprite_shape_size& shape_size, sprite_tiles_ptr tiles, sprite_palette_ptr palette) -> sprite_ptr
Creates a sprite_ptr.
static auto create(const sprite_builder& builder) -> sprite_ptr
Creates a sprite_ptr from a sprite_builder reference.
static auto create(sprite_builder&& builder) -> sprite_ptr
Creates a sprite_ptr from a moved sprite_builder.
static auto create_optional(const sprite_item& item) -> optional<sprite_ptr>
Creates a sprite_ptr from the given sprite_item.
static auto create_optional(const sprite_item& item, int graphics_index) -> optional<sprite_ptr>
Creates a sprite_ptr from the given sprite_item.
static auto create_optional(const sprite_shape_size& shape_size, sprite_tiles_ptr tiles, sprite_palette_ptr palette) -> optional<sprite_ptr>
Creates a sprite_ptr.
static auto create_optional(fixed x, fixed y, const sprite_item& item) -> optional<sprite_ptr>
Creates a sprite_ptr from the given sprite_item.
static auto create_optional(fixed x, fixed y, const sprite_item& item, int graphics_index) -> optional<sprite_ptr>
Creates a sprite_ptr from the given sprite_item.
static auto create_optional(const fixed_point& position, const sprite_item& item) -> optional<sprite_ptr>
Creates a sprite_ptr from the given sprite_item.
static auto create_optional(const fixed_point& position, const sprite_item& item, int graphics_index) -> optional<sprite_ptr>
Creates a sprite_ptr from the given sprite_item.
static auto create_optional(fixed x, fixed y, const sprite_shape_size& shape_size, sprite_tiles_ptr tiles, sprite_palette_ptr palette) -> optional<sprite_ptr>
Creates a sprite_ptr.
static auto create_optional(const fixed_point& position, const sprite_shape_size& shape_size, sprite_tiles_ptr tiles, sprite_palette_ptr palette) -> optional<sprite_ptr>
Creates a sprite_ptr.
static auto create_optional(const sprite_builder& builder) -> optional<sprite_ptr>
Creates a sprite_ptr from a sprite_builder reference.
static auto create_optional(sprite_builder&& builder) -> optional<sprite_ptr>
Creates a sprite_ptr from a moved sprite_builder.

Constructors, destructors, conversion operators

sprite_ptr(const sprite_ptr& other)
Copy constructor.
sprite_ptr(sprite_ptr&& other) noexcept
Move constructor.
~sprite_ptr()
Releases the referenced sprite if no more sprite_ptr objects reference to it.

Public functions

auto operator=(const sprite_ptr& other) -> sprite_ptr&
Copy assignment operator.
auto operator=(sprite_ptr&& other) -> sprite_ptr& noexcept
Move assignment operator.
auto shape_size() const -> sprite_shape_size
Returns the shape and size of the sprite.
auto dimensions() const -> size
Returns the size in pixels of the sprite.
auto tiles() const -> const sprite_tiles_ptr&
Returns the tiles used by this sprite.
void set_tiles(const sprite_tiles_ptr& tiles)
Sets the tiles used by this sprite.
void set_tiles(sprite_tiles_ptr&& tiles)
Sets the tiles used by this sprite.
void set_tiles(const sprite_shape_size& shape_size, const sprite_tiles_ptr& tiles)
Sets the tiles, the shape and size of the sprite.
void set_tiles(const sprite_shape_size& shape_size, sprite_tiles_ptr&& tiles)
Sets the tiles, the shape and size of the sprite.
void set_tiles(const sprite_tiles_item& tiles_item)
Replaces the tiles used by this sprite with a new tile set created with the given sprite_tiles_item.
void set_tiles(const sprite_tiles_item& tiles_item, int graphics_index)
Replaces the tiles used by this sprite with a new tile set created with the given sprite_tiles_item.
void set_tiles(const sprite_tiles_item& tiles_item, const sprite_shape_size& shape_size)
Replaces the tiles used by this sprite with a new tile set created with the given sprite_tiles_item, changing also the shape and size of the sprite.
void set_tiles(const sprite_tiles_item& tiles_item, const sprite_shape_size& shape_size, int graphics_index)
Replaces the tiles used by this sprite with a new tile set created with the given sprite_tiles_item, changing also the shape and size of the sprite.
auto palette() const -> const sprite_palette_ptr&
Returns the color palette used by this sprite.
void set_palette(const sprite_palette_ptr& palette)
Sets the color palette to use by this sprite.
void set_palette(sprite_palette_ptr&& palette)
Sets the color palette to use by this sprite.
void set_palette(const sprite_palette_item& palette_item)
Replaces the color palette used by this sprite with a new one created with the given sprite_palette_item.
void set_tiles_and_palette(sprite_tiles_ptr tiles, sprite_palette_ptr palette)
Sets the tiles and the color palette to use by this sprite.
void set_tiles_and_palette(const sprite_shape_size& shape_size, sprite_tiles_ptr tiles, sprite_palette_ptr palette)
Sets the tiles, the color palette, the shape and size to use by this sprite.
void set_item(const sprite_item& item)
Replaces the tiles, the color palette, the shape and size used by this sprite with the created with the given sprite_item.
void set_item(const sprite_item& item, int graphics_index)
Replaces the tiles, the color palette, the shape and size used by this sprite with the created with the given sprite_item.
auto x() const -> fixed
Returns the horizontal position of the sprite (relative to its camera, if it has one).
void set_x(fixed x)
Sets the horizontal position of the sprite (relative to its camera, if it has one).
auto y() const -> fixed
Returns the vertical position of the sprite (relative to its camera, if it has one).
void set_y(fixed y)
Sets the vertical position of the sprite (relative to its camera, if it has one).
auto position() const -> const fixed_point&
Returns the position of the sprite (relative to its camera, if it has one).
void set_position(fixed x, fixed y)
Sets the position of the sprite (relative to its camera, if it has one).
void set_position(const fixed_point& position)
Sets the position of the sprite (relative to its camera, if it has one).
auto top_left_x() const -> fixed
Returns the horizontal top-left position of the sprite (relative to its camera, if it has one).
void set_top_left_x(fixed top_left_x)
Sets the horizontal top-left position of the sprite (relative to its camera, if it has one).
auto top_left_y() const -> fixed
Returns the vertical top-left position of the sprite (relative to its camera, if it has one).
void set_top_left_y(fixed top_left_y)
Sets the vertical top-left position of the sprite (relative to its camera, if it has one).
auto top_left_position() const -> fixed_point
Returns the top-left position of the sprite (relative to its camera, if it has one).
void set_top_left_position(fixed top_left_x, fixed top_left_y)
Sets the top-left position of the sprite (relative to its camera, if it has one).
void set_top_left_position(const fixed_point& top_left_position)
Sets the top-left position of the sprite (relative to its camera, if it has one).
auto rotation_angle() const -> fixed
Returns the rotation angle in degrees of the sprite.
void set_rotation_angle(fixed rotation_angle)
Sets the rotation angle in degrees of the sprite.
void set_rotation_angle_safe(fixed rotation_angle)
Sets the rotation angle in degrees of the sprite.
auto horizontal_scale() const -> fixed
Returns the horizontal scale of the sprite.
void set_horizontal_scale(fixed horizontal_scale)
Sets the horizontal scale of the sprite.
auto vertical_scale() const -> fixed
Returns the vertical scale of the sprite.
void set_vertical_scale(fixed vertical_scale)
Sets the vertical scale of the sprite.
void set_scale(fixed scale)
Sets the scale of the sprite.
void set_scale(fixed horizontal_scale, fixed vertical_scale)
Sets the scale of the sprite.
auto horizontal_shear() const -> fixed
Returns the horizontal shear of the sprite.
void set_horizontal_shear(fixed horizontal_shear)
Sets the horizontal shear of the sprite.
auto vertical_shear() const -> fixed
Returns the vertical shear of the sprite.
void set_vertical_shear(fixed vertical_shear)
Sets the vertical shear of the sprite.
void set_shear(fixed shear)
Sets the shear of the sprite.
void set_shear(fixed horizontal_shear, fixed vertical_shear)
Sets the shear of the sprite.
auto bg_priority() const -> int
Returns the priority relative to backgrounds.
void set_bg_priority(int bg_priority)
Sets the priority relative to backgrounds.
auto z_order() const -> int
Returns the priority relative to other sprites.
void set_z_order(int z_order)
Sets the priority relative to other sprites.
void put_above()
Modify this sprite to be drawn above all of the other sprites with the same priority.
void put_below()
Modify this sprite to be drawn below all of the other sprites with the same priority.
auto horizontal_flip() const -> bool
Indicates if this sprite is flipped in the horizontal axis or not.
void set_horizontal_flip(bool horizontal_flip)
Sets if this sprite is flipped in the horizontal axis or not.
auto vertical_flip() const -> bool
Indicates if this sprite is flipped in the vertical axis or not.
void set_vertical_flip(bool vertical_flip)
Sets if this sprite is flipped in the vertical axis or not.
auto mosaic_enabled() const -> bool
Indicates if the mosaic effect must be applied to this sprite or not.
void set_mosaic_enabled(bool mosaic_enabled)
Sets if the mosaic effect must be applied to this sprite or not.
auto blending_enabled() const -> bool
Indicates if blending must be applied to this sprite or not.
void set_blending_enabled(bool blending_enabled)
Sets if blending must be applied to this sprite or not.
auto window_enabled() const -> bool
Indicates if this sprite must be part of the silhouette of the sprite window or not.
void set_window_enabled(bool window_enabled)
Sets if this sprite must be part of the silhouette of the sprite window or not.
auto double_size() const -> bool
Indicates if this sprite is being drawn using more pixels than the area specified by its shape and size or not.
auto double_size_mode() const -> sprite_double_size_mode
Returns the area this sprite uses to be drawn when it has an attached sprite_affine_mat_ptr.
void set_double_size_mode(sprite_double_size_mode double_size_mode)
Specifies the area this sprite uses to be drawn when it has an attached sprite_affine_mat_ptr.
auto visible() const -> bool
Indicates if this sprite must be committed to the GBA or not.
void set_visible(bool visible)
Sets if this sprite must be committed to the GBA or not.
auto camera() const -> const optional<camera_ptr>&
Returns the camera_ptr attached to this sprite (if any).
void set_camera(const camera_ptr& camera)
Sets the camera_ptr attached to this sprite.
void set_camera(camera_ptr&& camera)
Sets the camera_ptr attached to this sprite.
void set_camera(const optional<camera_ptr>& camera)
Sets or removes the camera_ptr attached to this sprite.
void set_camera(optional<camera_ptr>&& camera)
Sets or removes the camera_ptr attached to this sprite.
void remove_camera()
Removes the camera_ptr attached to this sprite (if any).
auto affine_mat() const -> const optional<sprite_affine_mat_ptr>&
Returns the sprite_affine_mat_ptr attached to this sprite (if any).
void set_affine_mat(const sprite_affine_mat_ptr& affine_mat)
Sets the sprite_affine_mat_ptr attached to this sprite.
void set_affine_mat(sprite_affine_mat_ptr&& affine_mat)
Sets the sprite_affine_mat_ptr attached to this sprite.
void set_affine_mat(const optional<sprite_affine_mat_ptr>& affine_mat)
Sets or removes the sprite_affine_mat_ptr attached to this sprite.
void set_affine_mat(optional<sprite_affine_mat_ptr>&& affine_mat)
Sets or removes the sprite_affine_mat_ptr attached to this sprite.
void remove_affine_mat()
Removes the sprite_affine_mat_ptr attached to this sprite (if any).
auto remove_affine_mat_when_not_needed() const -> bool
Indicates if the sprite_affine_mat_ptr attached to this sprite (if any) must be removed when it is not needed anymore.
void set_remove_affine_mat_when_not_needed(bool remove_when_not_needed)
Sets if the sprite_affine_mat_ptr attached to this sprite (if any) must be removed when it is not needed anymore.
auto first_attributes() const -> sprite_first_attributes
Returns the attributes to commit to the first GBA register of this sprite.
void set_first_attributes(const sprite_first_attributes& first_attributes)
Sets the attributes to commit to the first GBA register of this sprite.
auto regular_second_attributes() const -> sprite_regular_second_attributes
Returns the attributes to commit to the second GBA register of this sprite when it is regular (it does not have an attached sprite_affine_mat_ptr).
void set_regular_second_attributes(const sprite_regular_second_attributes& second_attributes)
Sets the attributes to commit to the second GBA register of this sprite when it is regular (it does not have an attached sprite_affine_mat_ptr).
auto affine_second_attributes() const -> sprite_affine_second_attributes
Returns the attributes to commit to the second GBA register of this sprite when it is affine (it hash an attached sprite_affine_mat_ptr).
void set_affine_second_attributes(const sprite_affine_second_attributes& second_attributes)
Sets the attributes to commit to the second GBA register of this sprite when it is affine (it hash an attached sprite_affine_mat_ptr).
auto third_attributes() const -> sprite_third_attributes
Returns the attributes to commit to the third GBA register of this sprite.
void set_third_attributes(const sprite_third_attributes& third_attributes)
Sets the attributes to commit to the third GBA register of this sprite.
auto handle() const -> const void*
Returns the internal handle.
void swap(sprite_ptr& other)
Exchanges the contents of this sprite_ptr with those of the other one.

Friends

void swap(sprite_ptr& a, sprite_ptr& b)
Exchanges the contents of a sprite_ptr with those of another one.
auto operator==(const sprite_ptr& a, const sprite_ptr& b) -> bool defaulted
Default equal operator.

Function documentation

static sprite_ptr bn::sprite_ptr::create(const sprite_item& item)

Creates a sprite_ptr from the given sprite_item.

Parameters
item sprite_item containing the required information to generate the sprite.
Returns The requested sprite_ptr.

static sprite_ptr bn::sprite_ptr::create(const sprite_item& item, int graphics_index)

Creates a sprite_ptr from the given sprite_item.

Parameters
item sprite_item containing the required information to generate the sprite.
graphics_index Index of the tile set to reference in item.tiles_item().
Returns The requested sprite_ptr.

static sprite_ptr bn::sprite_ptr::create(const sprite_shape_size& shape_size, sprite_tiles_ptr tiles, sprite_palette_ptr palette)

Creates a sprite_ptr.

Parameters
shape_size Shape and size of the sprite.
tiles Smart pointer to a sprite tile set.
palette Smart pointer to a sprite color palette.
Returns The requested sprite_ptr.

static sprite_ptr bn::sprite_ptr::create(fixed x, fixed y, const sprite_item& item)

Creates a sprite_ptr from the given sprite_item.

Parameters
x Horizontal position of the sprite.
y Vertical position of the sprite.
item sprite_item containing the required information to generate the sprite.
Returns The requested sprite_ptr.

static sprite_ptr bn::sprite_ptr::create(fixed x, fixed y, const sprite_item& item, int graphics_index)

Creates a sprite_ptr from the given sprite_item.

Parameters
x Horizontal position of the sprite.
y Vertical position of the sprite.
item sprite_item containing the required information to generate the sprite.
graphics_index Index of the tile set to reference in item.tiles_item().
Returns The requested sprite_ptr.

static sprite_ptr bn::sprite_ptr::create(const fixed_point& position, const sprite_item& item)

Creates a sprite_ptr from the given sprite_item.

Parameters
position Position of the sprite.
item sprite_item containing the required information to generate the sprite.
Returns The requested sprite_ptr.

static sprite_ptr bn::sprite_ptr::create(const fixed_point& position, const sprite_item& item, int graphics_index)

Creates a sprite_ptr from the given sprite_item.

Parameters
position Position of the sprite.
item sprite_item containing the required information to generate the sprite.
graphics_index Index of the tile set to reference in item.tiles_item().
Returns The requested sprite_ptr.

static sprite_ptr bn::sprite_ptr::create(fixed x, fixed y, const sprite_shape_size& shape_size, sprite_tiles_ptr tiles, sprite_palette_ptr palette)

Creates a sprite_ptr.

Parameters
x Horizontal position of the sprite.
y Vertical position of the sprite.
shape_size Shape and size of the sprite.
tiles Smart pointer to a sprite tile set.
palette Smart pointer to a sprite color palette.
Returns The requested sprite_ptr.

static sprite_ptr bn::sprite_ptr::create(const fixed_point& position, const sprite_shape_size& shape_size, sprite_tiles_ptr tiles, sprite_palette_ptr palette)

Creates a sprite_ptr.

Parameters
position Position of the sprite.
shape_size Shape and size of the sprite.
tiles Smart pointer to a sprite tile set.
palette Smart pointer to a sprite color palette.
Returns The requested sprite_ptr.

static sprite_ptr bn::sprite_ptr::create(const sprite_builder& builder)

Creates a sprite_ptr from a sprite_builder reference.

Parameters
builder sprite_builder reference.
Returns The requested sprite_ptr.

static sprite_ptr bn::sprite_ptr::create(sprite_builder&& builder)

Creates a sprite_ptr from a moved sprite_builder.

Parameters
builder sprite_builder to move.
Returns The requested sprite_ptr.

static optional<sprite_ptr> bn::sprite_ptr::create_optional(const sprite_item& item)

Creates a sprite_ptr from the given sprite_item.

Parameters
item sprite_item containing the required information to generate the sprite.
Returns The requested sprite_ptr if it could be allocated; bn::nullopt otherwise.

static optional<sprite_ptr> bn::sprite_ptr::create_optional(const sprite_item& item, int graphics_index)

Creates a sprite_ptr from the given sprite_item.

Parameters
item sprite_item containing the required information to generate the sprite.
graphics_index Index of the tile set to reference in item.tiles_item().
Returns The requested sprite_ptr if it could be allocated; bn::nullopt otherwise.

static optional<sprite_ptr> bn::sprite_ptr::create_optional(const sprite_shape_size& shape_size, sprite_tiles_ptr tiles, sprite_palette_ptr palette)

Creates a sprite_ptr.

Parameters
shape_size Shape and size of the sprite.
tiles Smart pointer to a sprite tile set.
palette Smart pointer to a sprite color palette.
Returns The requested sprite_ptr if it could be allocated; bn::nullopt otherwise.

static optional<sprite_ptr> bn::sprite_ptr::create_optional(fixed x, fixed y, const sprite_item& item)

Creates a sprite_ptr from the given sprite_item.

Parameters
x Horizontal position of the sprite.
y Vertical position of the sprite.
item sprite_item containing the required information to generate the sprite.
Returns The requested sprite_ptr if it could be allocated; bn::nullopt otherwise.

static optional<sprite_ptr> bn::sprite_ptr::create_optional(fixed x, fixed y, const sprite_item& item, int graphics_index)

Creates a sprite_ptr from the given sprite_item.

Parameters
x Horizontal position of the sprite.
y Vertical position of the sprite.
item sprite_item containing the required information to generate the sprite.
graphics_index Index of the tile set to reference in item.tiles_item().
Returns The requested sprite_ptr if it could be allocated; bn::nullopt otherwise.

static optional<sprite_ptr> bn::sprite_ptr::create_optional(const fixed_point& position, const sprite_item& item)

Creates a sprite_ptr from the given sprite_item.

Parameters
position Position of the sprite.
item sprite_item containing the required information to generate the sprite.
Returns The requested sprite_ptr if it could be allocated; bn::nullopt otherwise.

static optional<sprite_ptr> bn::sprite_ptr::create_optional(const fixed_point& position, const sprite_item& item, int graphics_index)

Creates a sprite_ptr from the given sprite_item.

Parameters
position Position of the sprite.
item sprite_item containing the required information to generate the sprite.
graphics_index Index of the tile set to reference in item.tiles_item().
Returns The requested sprite_ptr if it could be allocated; bn::nullopt otherwise.

static optional<sprite_ptr> bn::sprite_ptr::create_optional(fixed x, fixed y, const sprite_shape_size& shape_size, sprite_tiles_ptr tiles, sprite_palette_ptr palette)

Creates a sprite_ptr.

Parameters
x Horizontal position of the sprite.
y Vertical position of the sprite.
shape_size Shape and size of the sprite.
tiles Smart pointer to a sprite tile set.
palette Smart pointer to a sprite color palette.
Returns The requested sprite_ptr if it could be allocated; bn::nullopt otherwise.

static optional<sprite_ptr> bn::sprite_ptr::create_optional(const fixed_point& position, const sprite_shape_size& shape_size, sprite_tiles_ptr tiles, sprite_palette_ptr palette)

Creates a sprite_ptr.

Parameters
position Position of the sprite.
shape_size Shape and size of the sprite.
tiles Smart pointer to a sprite tile set.
palette Smart pointer to a sprite color palette.
Returns The requested sprite_ptr if it could be allocated; bn::nullopt otherwise.

static optional<sprite_ptr> bn::sprite_ptr::create_optional(const sprite_builder& builder)

Creates a sprite_ptr from a sprite_builder reference.

Parameters
builder sprite_builder reference.
Returns The requested sprite_ptr if it could be allocated; bn::nullopt otherwise.

static optional<sprite_ptr> bn::sprite_ptr::create_optional(sprite_builder&& builder)

Creates a sprite_ptr from a moved sprite_builder.

Parameters
builder sprite_builder to move.
Returns The requested sprite_ptr if it could be allocated; bn::nullopt otherwise.

bn::sprite_ptr::sprite_ptr(const sprite_ptr& other)

Copy constructor.

Parameters
other sprite_ptr to copy.

bn::sprite_ptr::sprite_ptr(sprite_ptr&& other) noexcept

Move constructor.

Parameters
other sprite_ptr to move.

sprite_ptr& bn::sprite_ptr::operator=(const sprite_ptr& other)

Copy assignment operator.

Parameters
other sprite_ptr to copy.
Returns Reference to this.

sprite_ptr& bn::sprite_ptr::operator=(sprite_ptr&& other) noexcept

Move assignment operator.

Parameters
other sprite_ptr to move.
Returns Reference to this.

void bn::sprite_ptr::set_tiles(const sprite_tiles_ptr& tiles)

Sets the tiles used by this sprite.

Parameters
tiles sprite_tiles_ptr to copy.

It must be compatible with the current color palette, shape and size of the sprite.

void bn::sprite_ptr::set_tiles(sprite_tiles_ptr&& tiles)

Sets the tiles used by this sprite.

Parameters
tiles sprite_tiles_ptr to move.

It must be compatible with the current color palette, shape and size of the sprite.

void bn::sprite_ptr::set_tiles(const sprite_shape_size& shape_size, const sprite_tiles_ptr& tiles)

Sets the tiles, the shape and size of the sprite.

Parameters
shape_size Shape and size of the sprite.
tiles sprite_tiles_ptr to copy.

It must be compatible with the current color palette of the sprite.

void bn::sprite_ptr::set_tiles(const sprite_shape_size& shape_size, sprite_tiles_ptr&& tiles)

Sets the tiles, the shape and size of the sprite.

Parameters
shape_size Shape and size of the sprite.
tiles sprite_tiles_ptr to move.

It must be compatible with the current color palette of the sprite.

void bn::sprite_ptr::set_tiles(const sprite_tiles_item& tiles_item)

Replaces the tiles used by this sprite with a new tile set created with the given sprite_tiles_item.

Parameters
tiles_item It creates the new sprite tiles to use by this sprite.

Before creating a new sprite tile set, the sprite_tiles_ptr used by this sprite is removed, so VRAM usage is reduced.

The new sprite tiles must be compatible with the current color palette, shape and size of the sprite.

void bn::sprite_ptr::set_tiles(const sprite_tiles_item& tiles_item, int graphics_index)

Replaces the tiles used by this sprite with a new tile set created with the given sprite_tiles_item.

Parameters
tiles_item It creates the sprite tiles to use by this sprite.
graphics_index Index of the tile set to reference in tiles_item.

Before creating a new sprite tile set, the sprite_tiles_ptr used by this sprite is removed, so VRAM usage is reduced.

The new sprite tiles must be compatible with the current color palette, shape and size of the sprite.

void bn::sprite_ptr::set_tiles(const sprite_tiles_item& tiles_item, const sprite_shape_size& shape_size)

Replaces the tiles used by this sprite with a new tile set created with the given sprite_tiles_item, changing also the shape and size of the sprite.

Parameters
tiles_item It creates the sprite tiles to use by this sprite.
shape_size Shape and size of the sprite.

Before creating a new sprite tile set, the sprite_tiles_ptr used by this sprite is removed, so VRAM usage is reduced.

The new sprite tiles must be compatible with the current color palette of the sprite.

void bn::sprite_ptr::set_tiles(const sprite_tiles_item& tiles_item, const sprite_shape_size& shape_size, int graphics_index)

Replaces the tiles used by this sprite with a new tile set created with the given sprite_tiles_item, changing also the shape and size of the sprite.

Parameters
tiles_item It creates the sprite tiles to use by this sprite.
shape_size Shape and size of the sprite.
graphics_index Index of the tile set to reference in tiles_item.

Before creating a new sprite tile set, the sprite_tiles_ptr used by this sprite is removed, so VRAM usage is reduced.

The new sprite tiles must be compatible with the current color palette of the sprite.

void bn::sprite_ptr::set_palette(const sprite_palette_ptr& palette)

Sets the color palette to use by this sprite.

Parameters
palette sprite_palette_ptr to copy.

It must be compatible with the current tiles of the sprite.

void bn::sprite_ptr::set_palette(sprite_palette_ptr&& palette)

Sets the color palette to use by this sprite.

Parameters
palette sprite_palette_ptr to move.

It must be compatible with the current tiles of the sprite.

void bn::sprite_ptr::set_palette(const sprite_palette_item& palette_item)

Replaces the color palette used by this sprite with a new one created with the given sprite_palette_item.

Parameters
palette_item It creates the color palette to use by this sprite.

Before creating a new color palette, the sprite_palette_ptr used by this sprite is removed, so VRAM usage is reduced.

The new color palette must be compatible with the current tiles of the sprite.

void bn::sprite_ptr::set_tiles_and_palette(sprite_tiles_ptr tiles, sprite_palette_ptr palette)

Sets the tiles and the color palette to use by this sprite.

Parameters
tiles sprite_tiles_ptr to set.
palette sprite_palette_ptr to set.

The given parameters must be compatible with the current shape and size of the sprite.

void bn::sprite_ptr::set_tiles_and_palette(const sprite_shape_size& shape_size, sprite_tiles_ptr tiles, sprite_palette_ptr palette)

Sets the tiles, the color palette, the shape and size to use by this sprite.

Parameters
shape_size Shape and size of the sprite.
tiles sprite_tiles_ptr to set.
palette sprite_palette_ptr to set.

void bn::sprite_ptr::set_item(const sprite_item& item)

Replaces the tiles, the color palette, the shape and size used by this sprite with the created with the given sprite_item.

Parameters
item It creates the resources to use by this sprite.

Before creating new resources, the resources used by this sprite are removed, so VRAM usage is reduced.

void bn::sprite_ptr::set_item(const sprite_item& item, int graphics_index)

Replaces the tiles, the color palette, the shape and size used by this sprite with the created with the given sprite_item.

Parameters
item It creates the resources to use by this sprite.
graphics_index Index of the tile set to reference in item.tiles_item().

Before creating new resources, the resources used by this sprite are removed, so VRAM usage is reduced.

void bn::sprite_ptr::set_position(fixed x, fixed y)

Sets the position of the sprite (relative to its camera, if it has one).

Parameters
x Horizontal position of the sprite (relative to its camera, if it has one).
y Vertical position of the sprite (relative to its camera, if it has one).

void bn::sprite_ptr::set_top_left_position(fixed top_left_x, fixed top_left_y)

Sets the top-left position of the sprite (relative to its camera, if it has one).

Parameters
top_left_x Horizontal top-left position of the sprite (relative to its camera, if it has one).
top_left_y Vertical top-left position of the sprite (relative to its camera, if it has one).

void bn::sprite_ptr::set_rotation_angle(fixed rotation_angle)

Sets the rotation angle in degrees of the sprite.

Parameters
rotation_angle Rotation angle in degrees, in the range [0..360].

If the rotation angle is != 0 and the sprite doesn't have an attached sprite_affine_mat_ptr, a new one with the given rotation angle is attached to it.

void bn::sprite_ptr::set_rotation_angle_safe(fixed rotation_angle)

Sets the rotation angle in degrees of the sprite.

Parameters
rotation_angle Rotation angle in degrees, in any range.

If the rotation angle is != 0 and the sprite doesn't have an attached sprite_affine_mat_ptr, a new one with the given rotation angle is attached to it.

void bn::sprite_ptr::set_horizontal_scale(fixed horizontal_scale)

Sets the horizontal scale of the sprite.

If the horizontal scale is != 1 and the sprite doesn't have an attached sprite_affine_mat_ptr, a new one with the given horizontal scale is attached to it.

void bn::sprite_ptr::set_vertical_scale(fixed vertical_scale)

Sets the vertical scale of the sprite.

If the vertical scale is != 1 and the sprite doesn't have an attached sprite_affine_mat_ptr, a new one with the given vertical scale is attached to it.

void bn::sprite_ptr::set_scale(fixed scale)

Sets the scale of the sprite.

If the scale is != 1 and the sprite doesn't have an attached sprite_affine_mat_ptr, a new one with the given scale is attached to it.

void bn::sprite_ptr::set_scale(fixed horizontal_scale, fixed vertical_scale)

Sets the scale of the sprite.

Parameters
horizontal_scale Horizontal scale.
vertical_scale Vertical scale.

If the scale is != 1 and the sprite doesn't have an attached sprite_affine_mat_ptr, a new one with the given scale is attached to it.

void bn::sprite_ptr::set_horizontal_shear(fixed horizontal_shear)

Sets the horizontal shear of the sprite.

If the horizontal shear is != 0 and the sprite doesn't have an attached sprite_affine_mat_ptr, a new one with the given horizontal shear is attached to it.

void bn::sprite_ptr::set_vertical_shear(fixed vertical_shear)

Sets the vertical shear of the sprite.

If the vertical shear is != 0 and the sprite doesn't have an attached sprite_affine_mat_ptr, a new one with the given vertical shear is attached to it.

void bn::sprite_ptr::set_shear(fixed shear)

Sets the shear of the sprite.

If the shear is != 0 and the sprite doesn't have an attached sprite_affine_mat_ptr, a new one with the given shear is attached to it.

void bn::sprite_ptr::set_shear(fixed horizontal_shear, fixed vertical_shear)

Sets the shear of the sprite.

Parameters
horizontal_shear Horizontal shear.
vertical_shear Vertical shear.

If the shear is != 0 and the sprite doesn't have an attached sprite_affine_mat_ptr, a new one with the given shear is attached to it.

int bn::sprite_ptr::bg_priority() const

Returns the priority relative to backgrounds.

Sprites with higher priority are drawn first (and therefore can be covered by later sprites and backgrounds). Sprites cover backgrounds of the same priority.

void bn::sprite_ptr::set_bg_priority(int bg_priority)

Sets the priority relative to backgrounds.

Parameters
bg_priority Priority relative to backgrounds in the range [0..3].

Sprites with higher priority are drawn first (and therefore can be covered by later sprites and backgrounds). Sprites cover backgrounds of the same priority.

int bn::sprite_ptr::z_order() const

Returns the priority relative to other sprites.

Sprites with higher z orders are drawn first (and therefore can be covered by later sprites).

Sprites are grouped in layers depending of their background priority and z order, so to reduce memory usage and improve performance, please use as less unique z orders as possible.

void bn::sprite_ptr::set_z_order(int z_order)

Sets the priority relative to other sprites.

Parameters
z_order Priority relative to other sprites in the range [-32767..32767].

Sprites with higher z orders are drawn first (and therefore can be covered by later sprites).

Sprites are grouped in layers depending of their background priority and z order, so to reduce memory usage and improve performance, please use as less unique z orders as possible.

bool bn::sprite_ptr::blending_enabled() const

Indicates if blending must be applied to this sprite or not.

Keep in mind that blending and window attributes can't be enabled at the same time.

void bn::sprite_ptr::set_blending_enabled(bool blending_enabled)

Sets if blending must be applied to this sprite or not.

Keep in mind that blending and window attributes can't be enabled at the same time.

bool bn::sprite_ptr::window_enabled() const

Indicates if this sprite must be part of the silhouette of the sprite window or not.

Keep in mind that blending and window attributes can't be enabled at the same time.

void bn::sprite_ptr::set_window_enabled(bool window_enabled)

Sets if this sprite must be part of the silhouette of the sprite window or not.

Keep in mind that blending and window attributes can't be enabled at the same time.

void bn::sprite_ptr::set_camera(const camera_ptr& camera)

Sets the camera_ptr attached to this sprite.

Parameters
camera camera_ptr to copy to this sprite.

void bn::sprite_ptr::set_camera(camera_ptr&& camera)

Sets the camera_ptr attached to this sprite.

Parameters
camera camera_ptr to move to this sprite.

void bn::sprite_ptr::set_camera(const optional<camera_ptr>& camera)

Sets or removes the camera_ptr attached to this sprite.

Parameters
camera Optional camera_ptr to copy to this sprite.

void bn::sprite_ptr::set_camera(optional<camera_ptr>&& camera)

Sets or removes the camera_ptr attached to this sprite.

Parameters
camera Optional camera_ptr to move to this sprite.

void bn::sprite_ptr::set_affine_mat(const sprite_affine_mat_ptr& affine_mat)

Sets the sprite_affine_mat_ptr attached to this sprite.

Parameters
affine_mat sprite_affine_mat_ptr to copy to this sprite.

This method calls set_remove_affine_mat_when_not_needed(false).

void bn::sprite_ptr::set_affine_mat(sprite_affine_mat_ptr&& affine_mat)

Sets the sprite_affine_mat_ptr attached to this sprite.

Parameters
affine_mat sprite_affine_mat_ptr to move to this sprite.

This method calls set_remove_affine_mat_when_not_needed(false).

void bn::sprite_ptr::set_affine_mat(const optional<sprite_affine_mat_ptr>& affine_mat)

Sets or removes the sprite_affine_mat_ptr attached to this sprite.

Parameters
affine_mat Optional sprite_affine_mat_ptr to copy to this sprite.

This method calls set_remove_affine_mat_when_not_needed(false) if the given sprite_affine_mat_ptr is not null.

void bn::sprite_ptr::set_affine_mat(optional<sprite_affine_mat_ptr>&& affine_mat)

Sets or removes the sprite_affine_mat_ptr attached to this sprite.

Parameters
affine_mat Optional sprite_affine_mat_ptr to move to this sprite.

This method calls set_remove_affine_mat_when_not_needed(false) if the given sprite_affine_mat_ptr is not null.

bool bn::sprite_ptr::remove_affine_mat_when_not_needed() const

Indicates if the sprite_affine_mat_ptr attached to this sprite (if any) must be removed when it is not needed anymore.

A sprite does not need an sprite_affine_mat_ptr when its flipped_identity() method returns true.

void bn::sprite_ptr::set_remove_affine_mat_when_not_needed(bool remove_when_not_needed)

Sets if the sprite_affine_mat_ptr attached to this sprite (if any) must be removed when it is not needed anymore.

A sprite does not need an sprite_affine_mat_ptr when its flipped_identity() method returns true.

void bn::sprite_ptr::swap(sprite_ptr& other)

Exchanges the contents of this sprite_ptr with those of the other one.

Parameters
other sprite_ptr to exchange the contents with.

void swap(sprite_ptr& a, sprite_ptr& b)

Exchanges the contents of a sprite_ptr with those of another one.

Parameters
a First sprite_ptr to exchange the contents with.
b Second sprite_ptr to exchange the contents with.