ldtk::level_bgs_ptr class

Public static functions

static auto create(const level& level) -> level_bgs_ptr
Creates a level_bgs_ptr from the given level.
static auto create(const bn::fixed_point& position, const level& level) -> level_bgs_ptr
Creates a level_bgs_ptr from the given level.
static auto create(bn::fixed x, bn::fixed y, const level& level) -> level_bgs_ptr
Creates a level_bgs_ptr from the given level.
static auto create(const level_bgs_builder& builder) -> level_bgs_ptr
Creates a level_bgs_ptr from a level_bgs_builder reference.
static auto create(level_bgs_builder&& builder) -> level_bgs_ptr
Creates a level_bgs_ptr from a moved level_bgs_builder.
static auto create_optional(const level& level) -> bn::optional<level_bgs_ptr>
Creates a level_bgs_ptr from the given level.
static auto create_optional(const bn::fixed_point& position, const level& level) -> bn::optional<level_bgs_ptr>
Creates a level_bgs_ptr from the given level.
static auto create_optional(bn::fixed x, bn::fixed y, const level& level) -> bn::optional<level_bgs_ptr>
Creates a level_bgs_ptr from the given level.
static auto create_optional(const level_bgs_builder& builder) -> bn::optional<level_bgs_ptr>
Creates a level_bgs_ptr from a level_bgs_builder reference.
static auto create_optional(level_bgs_builder&& builder) -> bn::optional<level_bgs_ptr>
Creates a level_bgs_ptr from a moved level_bgs_builder.

Constructors, destructors, conversion operators

level_bgs_ptr(const level_bgs_ptr& other)
Copy constructor.
level_bgs_ptr(level_bgs_ptr&& other) noexcept
Move constructor.
~level_bgs_ptr()
Releases the referenced level backgrounds if no more level_bgs_ptr objects reference to them.

Public functions

auto operator=(const level_bgs_ptr& other) -> level_bgs_ptr&
Copy assignment operator.
auto operator=(level_bgs_ptr&& other) -> level_bgs_ptr& noexcept
Move assignment operator.
auto has_background(gen::layer_ident layer_identifier) const -> bool
Checks if the given layer has a background generated or not.
void set_level(const level& level)
Replace the level used by these level backgrounds.
void set_level(const level_bgs_builder& builder)
Replace the level used by these level backgrounds.
void set_level(level_bgs_builder&& builder)
Replace the level used by these level backgrounds.
auto palette(gen::layer_ident layer_identifier) const -> const bn::bg_palette_ptr&
Returns the color palette used by a level background of the given layer.
void set_palette(const bn::bg_palette_ptr& palette)
Sets the color palette to use by these level backgrounds.
void set_palette(const bn::bg_palette_ptr& palette, gen::layer_ident layer_identifier)
Sets the color palette to use by a level background of the given layer.
void set_palette(bn::bg_palette_ptr&& palette)
Sets the color palette to use by these level backgrounds.
void set_palette(bn::bg_palette_ptr&& palette, gen::layer_ident layer_identifier)
Sets the color palette to use by a level background of the given layer.
void set_palette(const bn::bg_palette_item& palette_item)
Replaces the color palette used by these level backgrounds with a new one created with the given bn::bg_palette_item.
void set_palette(const bn::bg_palette_item& palette_item, gen::layer_ident layer_identifier)
Replaces the color palette used by a level background of the given layer with a new one created with the given bn::bg_palette_item.
auto dimensions() const -> bn::size
Returns the size in pixels of the level backgrounds.
auto x() const -> bn::fixed
Returns the horizontal position of the level backgrounds (relative to its camera, if they have one).
void set_x(bn::fixed x)
Sets the horizontal position of the level backgrounds (relative to its camera, if they have one).
auto y() const -> bn::fixed
Returns the vertical position of the level backgrounds (relative to its camera, if they have one).
void set_y(bn::fixed y)
Sets the vertical position of the level backgrounds (relative to its camera, if they have one).
auto position() const -> const bn::fixed_point&
Returns the position of the level backgrounds (relative to its camera, if they have one).
void set_position(bn::fixed x, bn::fixed y)
Sets the position of the level backgrounds (relative to its camera, if they have one).
void set_position(const bn::fixed_point& position)
Sets the position of the level backgrounds (relative to its camera, if they have one).
auto top_left_x() const -> bn::fixed
Returns the horizontal top-left position of the level backgrounds (relative to its camera, if they have one).
void set_top_left_x(bn::fixed top_left_x)
Sets the horizontal top-left position of the level backgrounds (relative to its camera, if they have one).
auto top_left_y() const -> bn::fixed
Returns the vertical top-left position of the level backgrounds (relative to its camera, if they have one).
void set_top_left_y(bn::fixed top_left_y)
Sets the vertical top-left position of the level backgrounds (relative to its camera, if they have one).
auto top_left_position() const -> bn::fixed_point
Returns the top-left position of the level backgrounds (relative to its camera, if they have one).
void set_top_left_position(bn::fixed top_left_x, bn::fixed top_left_y)
Sets the top-left position of the level backgrounds (relative to its camera, if they have one).
void set_top_left_position(const bn::fixed_point& top_left_position)
Sets the top-left position of the level backgrounds (relative to its camera, if they have one).
auto priority(gen::layer_ident layer_identifier) const -> int
Returns the priority of a level background of the given layer relative to sprites and other backgrounds.
void set_priority(int priority)
Sets the priority of the level backgrounds relative to sprites and other backgrounds.
void set_priority(int priority, gen::layer_ident layer_identifier)
Sets the priority of a level background of the given layer relative to sprites and other backgrounds.
auto z_order(gen::layer_ident layer_identifier) const -> int
Returns the priority of a level background of the given layer relative to other backgrounds, excluding sprites.
void set_z_order(int z_order)
Sets the priority of the level backgrounds relative to other backgrounds, excluding sprites.
void set_z_order(int z_order, gen::layer_ident layer_identifier)
Sets the priority of a level background of the given layer relative to other backgrounds, excluding sprites.
void put_above()
Modify these level backgrounds to be drawn above all of the other backgrounds with the same priority.
void put_above(gen::layer_ident layer_identifier)
Modify a level background of the given layer to be drawn above all of the other backgrounds with the same priority.
void put_below()
Modify these level backgrounds to be drawn below all of the other backgrounds with the same priority.
void put_below(gen::layer_ident layer_identifier)
Modify a level background of the given layer to be drawn below all of the other backgrounds with the same priority.
auto mosaic_enabled(gen::layer_ident layer_identifier) const -> bool
Indicates if the mosaic effect must be applied to a level background with the given layer or not.
void set_mosaic_enabled(bool mosaic_enabled)
Sets if the mosaic effect must be applied to these level backgrounds or not.
void set_mosaic_enabled(bool mosaic_enabled, gen::layer_ident layer_identifier)
Sets if the mosaic effect must be applied to a level background of the given layer or not.
auto blending_enabled(gen::layer_ident layer_identifier) const -> bool
Indicates if blending must be applied to a level background with the given layer or not.
void set_blending_enabled(bool blending_enabled)
Sets if blending must be applied to these level backgrounds or not.
void set_blending_enabled(bool blending_enabled, gen::layer_ident layer_identifier)
Sets if blending must be applied to these level backgrounds or not.
auto blending_top_enabled(gen::layer_ident layer_identifier) const -> bool
Indicates if a level background with the given layer is part of the blending top layer or not.
void set_blending_top_enabled(bool blending_top_enabled)
Sets if these level backgrounds is part of the blending top layer or not.
void set_blending_top_enabled(bool blending_top_enabled, gen::layer_ident layer_identifier)
Sets if a level background of the given layer is part of the blending top layer or not.
auto blending_bottom_enabled(gen::layer_ident layer_identifier) const -> bool
Indicates if a level background with the given layer is part of the blending bottom layer or not.
void set_blending_bottom_enabled(bool blending_bottom_enabled)
Sets if these level backgrounds is part of the blending bottom layer or not.
void set_blending_bottom_enabled(bool blending_bottom_enabled, gen::layer_ident layer_identifier)
Sets if a level background of the given layer is part of the blending bottom layer or not.
auto green_swap_mode(gen::layer_ident layer_identifier) const -> bn::green_swap_mode
Indicates how a level background with the given layer must be displayed when green swap is enabled.
void set_green_swap_mode(bn::green_swap_mode green_swap_mode)
Sets how these level backgrounds must be displayed when green swap is enabled.
void set_green_swap_mode(bn::green_swap_mode green_swap_mode, gen::layer_ident layer_identifier)
Sets how a level background of the given layer must be displayed when green swap is enabled.
auto visible(gen::layer_ident layer_identifier) const -> bool
Indicates if a level background with the given layer must be committed to the GBA or not.
void set_visible(bool visible)
Sets if these level backgrounds must be committed to the GBA or not.
void set_visible(bool visible, gen::layer_ident layer_identifier)
Sets if a level background of the given layer must be committed to the GBA or not.
auto visible_in_window(const bn::window& window, gen::layer_ident layer_identifier) const -> bool
Indicates if a level background with the given layer is visible in the given window or not.
void set_visible_in_window(bool visible, bn::window& window)
Sets if these level backgrounds must be visible in the given window or not.
void set_visible_in_window(bool visible, bn::window& window, gen::layer_ident layer_identifier)
Sets if a level background of the given layer must be visible in the given window or not.
auto camera() const -> const bn::optional<bn::camera_ptr>&
Returns the bn::camera_ptr attached to these level backgrounds (if any).
void set_camera(const bn::camera_ptr& camera)
Sets the bn::camera_ptr attached to these level backgrounds.
void set_camera(bn::camera_ptr&& camera)
Sets the bn::camera_ptr attached to these level backgrounds.
void set_camera(const bn::optional<bn::camera_ptr>& camera)
Sets or removes the bn::camera_ptr attached to these level backgrounds.
void set_camera(bn::optional<bn::camera_ptr>&& camera)
Sets or removes the bn::camera_ptr attached to these level backgrounds.
void remove_camera()
Removes the bn::camera_ptr attached to these level backgrounds (if any).
auto out_of_bound_tile_info(gen::layer_ident layer_identifier) const -> tile_grid_base::tile_info
Returns the tile info that fills the out-of-bound region of a level background.
void set_out_of_bound_tile_info(tile_grid_base::tile_info oob_tile_info, gen::layer_ident layer_identifier)
Sets the tile info that fills the out-of-bound region of a level background.
auto handle() const -> void * -> const auto
Returns the internal handle.
void swap(level_bgs_ptr& other) noexcept
Exchanges the contents of this level_bgs_ptr with those of the other one.

Friends

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

Function documentation

static level_bgs_ptr ldtk::level_bgs_ptr::create(const level& level)

Creates a level_bgs_ptr from the given level.

Returns The requested level_bgs_ptr.

static level_bgs_ptr ldtk::level_bgs_ptr::create(const bn::fixed_point& position, const level& level)

Creates a level_bgs_ptr from the given level.

Returns The requested level_bgs_ptr.

static level_bgs_ptr ldtk::level_bgs_ptr::create(bn::fixed x, bn::fixed y, const level& level)

Creates a level_bgs_ptr from the given level.

Returns The requested level_bgs_ptr.

static level_bgs_ptr ldtk::level_bgs_ptr::create(const level_bgs_builder& builder)

Creates a level_bgs_ptr from a level_bgs_builder reference.

Parameters
builder level_bgs_builder reference.
Returns The requested level_bgs_ptr.

static level_bgs_ptr ldtk::level_bgs_ptr::create(level_bgs_builder&& builder)

Creates a level_bgs_ptr from a moved level_bgs_builder.

Parameters
builder level_bgs_builder to move.
Returns The requested level_bgs_ptr.

static bn::optional<level_bgs_ptr> ldtk::level_bgs_ptr::create_optional(const level& level)

Creates a level_bgs_ptr from the given level.

Returns The requested level_bgs_ptr if it could be allocated; bn::nullopt otherwise.

static bn::optional<level_bgs_ptr> ldtk::level_bgs_ptr::create_optional(const bn::fixed_point& position, const level& level)

Creates a level_bgs_ptr from the given level.

Returns The requested level_bgs_ptr if it could be allocated; bn::nullopt otherwise.

static bn::optional<level_bgs_ptr> ldtk::level_bgs_ptr::create_optional(bn::fixed x, bn::fixed y, const level& level)

Creates a level_bgs_ptr from the given level.

Returns The requested level_bgs_ptr if it could be allocated; bn::nullopt otherwise.

static bn::optional<level_bgs_ptr> ldtk::level_bgs_ptr::create_optional(const level_bgs_builder& builder)

Creates a level_bgs_ptr from a level_bgs_builder reference.

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

static bn::optional<level_bgs_ptr> ldtk::level_bgs_ptr::create_optional(level_bgs_builder&& builder)

Creates a level_bgs_ptr from a moved level_bgs_builder.

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

ldtk::level_bgs_ptr::level_bgs_ptr(const level_bgs_ptr& other)

Copy constructor.

Parameters
other level_bgs_ptr to copy.

ldtk::level_bgs_ptr::level_bgs_ptr(level_bgs_ptr&& other) noexcept

Move constructor.

Parameters
other level_bgs_ptr to move.

level_bgs_ptr& ldtk::level_bgs_ptr::operator=(const level_bgs_ptr& other)

Copy assignment operator.

Parameters
other level_bgs_ptr to copy.
Returns Reference to this.

level_bgs_ptr& ldtk::level_bgs_ptr::operator=(level_bgs_ptr&& other) noexcept

Move assignment operator.

Parameters
other level_bgs_ptr to move.
Returns Reference to this.

bool ldtk::level_bgs_ptr::has_background(gen::layer_ident layer_identifier) const

Checks if the given layer has a background generated or not.

Parameters
layer_identifier identifier of the layer to check if it has a generated background.

void ldtk::level_bgs_ptr::set_level(const level_bgs_builder& builder)

Replace the level used by these level backgrounds.

Parameters
builder It creates the resources to use by this level builder.

void ldtk::level_bgs_ptr::set_level(level_bgs_builder&& builder)

Replace the level used by these level backgrounds.

Parameters
builder It creates the resources to use by this level builder.

const bn::bg_palette_ptr& ldtk::level_bgs_ptr::palette(gen::layer_ident layer_identifier) const

Returns the color palette used by a level background of the given layer.

Parameters
layer_identifier identifier of the layer to get the palette from.

void ldtk::level_bgs_ptr::set_palette(const bn::bg_palette_ptr& palette)

Sets the color palette to use by these level backgrounds.

It must be compatible with the current map of these level backgrounds.

void ldtk::level_bgs_ptr::set_palette(const bn::bg_palette_ptr& palette, gen::layer_ident layer_identifier)

Sets the color palette to use by a level background of the given layer.

Parameters
palette
layer_identifier identifier of the layer to set the palette to.

It must be compatible with the current map of the level background of the given layer.

void ldtk::level_bgs_ptr::set_palette(bn::bg_palette_ptr&& palette)

Sets the color palette to use by these level backgrounds.

It must be compatible with the current map of these level backgrounds.

void ldtk::level_bgs_ptr::set_palette(bn::bg_palette_ptr&& palette, gen::layer_ident layer_identifier)

Sets the color palette to use by a level background of the given layer.

Parameters
palette
layer_identifier identifier of the layer to set the palette to.

It must be compatible with the current map of the level background of the given layer.

void ldtk::level_bgs_ptr::set_palette(const bn::bg_palette_item& palette_item)

Replaces the color palette used by these level backgrounds with a new one created with the given bn::bg_palette_item.

Parameters
palette_item It creates the color palette to use by these level backgrounds.

Before creating a new color palette, the bn::bg_palette_ptr used by these level backgrounds are removed, so VRAM usage is reduced.

The new color palette must be compatible with the current map of these level backgrounds.

void ldtk::level_bgs_ptr::set_palette(const bn::bg_palette_item& palette_item, gen::layer_ident layer_identifier)

Replaces the color palette used by a level background of the given layer with a new one created with the given bn::bg_palette_item.

Parameters
palette_item It creates the color palette to use by a level background of the given layer.
layer_identifier identifier of the layer to set the palette to.

Before creating a new color palette, the bn::bg_palette_ptr used by the level background of the given layer is removed, so VRAM usage is reduced.

The new color palette must be compatible with the current map of the level background of the given layer.

int ldtk::level_bgs_ptr::priority(gen::layer_ident layer_identifier) const

Returns the priority of a level background of the given layer relative to sprites and other backgrounds.

Parameters
layer_identifier identifier of the layer to get the background priority from.

Backgrounds with higher priority are drawn first (and therefore can be covered by later sprites and backgrounds).

void ldtk::level_bgs_ptr::set_priority(int priority)

Sets the priority of the level backgrounds relative to sprites and other backgrounds.

Backgrounds with higher priority are drawn first (and therefore can be covered by later sprites and backgrounds).

void ldtk::level_bgs_ptr::set_priority(int priority, gen::layer_ident layer_identifier)

Sets the priority of a level background of the given layer relative to sprites and other backgrounds.

Parameters
priority
layer_identifier identifier of the layer to set the background priority to.

Backgrounds with higher priority are drawn first (and therefore can be covered by later sprites and backgrounds).

int ldtk::level_bgs_ptr::z_order(gen::layer_ident layer_identifier) const

Returns the priority of a level background of the given layer relative to other backgrounds, excluding sprites.

Parameters
layer_identifier identifier of the layer to get the background priority from.

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

Due to hardware limitations, affine backgrounds can be drawn before regular backgrounds with higher z order.

void ldtk::level_bgs_ptr::set_z_order(int z_order)

Sets the priority of the level backgrounds relative to other backgrounds, excluding sprites.

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

Due to hardware limitations, affine backgrounds can be drawn before regular backgrounds with higher z order.

void ldtk::level_bgs_ptr::set_z_order(int z_order, gen::layer_ident layer_identifier)

Sets the priority of a level background of the given layer relative to other backgrounds, excluding sprites.

Parameters
z_order
layer_identifier identifier of the layer to set the background priority to.

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

Due to hardware limitations, affine backgrounds can be drawn before regular backgrounds with higher z order.

void ldtk::level_bgs_ptr::put_above(gen::layer_ident layer_identifier)

Modify a level background of the given layer to be drawn above all of the other backgrounds with the same priority.

Parameters
layer_identifier identifier of the layer to put above.

void ldtk::level_bgs_ptr::put_below(gen::layer_ident layer_identifier)

Modify a level background of the given layer to be drawn below all of the other backgrounds with the same priority.

Parameters
layer_identifier identifier of the layer to put below.

bool ldtk::level_bgs_ptr::mosaic_enabled(gen::layer_ident layer_identifier) const

Indicates if the mosaic effect must be applied to a level background with the given layer or not.

Parameters
layer_identifier identifier of the layer to get the flag from.

void ldtk::level_bgs_ptr::set_mosaic_enabled(bool mosaic_enabled, gen::layer_ident layer_identifier)

Sets if the mosaic effect must be applied to a level background of the given layer or not.

Parameters
mosaic_enabled
layer_identifier identifier of the layer to set the flag to.

bool ldtk::level_bgs_ptr::blending_enabled(gen::layer_ident layer_identifier) const

Indicates if blending must be applied to a level background with the given layer or not.

Parameters
layer_identifier identifier of the layer to get the flag from.

Blending is applied to these level backgrounds by making it part of the blending top layer.

void ldtk::level_bgs_ptr::set_blending_enabled(bool blending_enabled)

Sets if blending must be applied to these level backgrounds or not.

Blending is applied to these level backgrounds by making it part of the blending top layer.

void ldtk::level_bgs_ptr::set_blending_enabled(bool blending_enabled, gen::layer_ident layer_identifier)

Sets if blending must be applied to these level backgrounds or not.

Parameters
blending_enabled
layer_identifier identifier of the layer to set the flag to.

Blending is applied to these level backgrounds by making it part of the blending top layer.

bool ldtk::level_bgs_ptr::blending_top_enabled(gen::layer_ident layer_identifier) const

Indicates if a level background with the given layer is part of the blending top layer or not.

Parameters
layer_identifier identifier of the layer to get the flag from.

void ldtk::level_bgs_ptr::set_blending_top_enabled(bool blending_top_enabled, gen::layer_ident layer_identifier)

Sets if a level background of the given layer is part of the blending top layer or not.

Parameters
blending_top_enabled
layer_identifier identifier of the layer to set the flag to.

bool ldtk::level_bgs_ptr::blending_bottom_enabled(gen::layer_ident layer_identifier) const

Indicates if a level background with the given layer is part of the blending bottom layer or not.

Parameters
layer_identifier identifier of the layer to get the flag from.

void ldtk::level_bgs_ptr::set_blending_bottom_enabled(bool blending_bottom_enabled, gen::layer_ident layer_identifier)

Sets if a level background of the given layer is part of the blending bottom layer or not.

Parameters
blending_bottom_enabled
layer_identifier identifier of the layer to set the flag to.

bn::green_swap_mode ldtk::level_bgs_ptr::green_swap_mode(gen::layer_ident layer_identifier) const

Indicates how a level background with the given layer must be displayed when green swap is enabled.

Parameters
layer_identifier identifier of the layer to get the mode from.

void ldtk::level_bgs_ptr::set_green_swap_mode(bn::green_swap_mode green_swap_mode, gen::layer_ident layer_identifier)

Sets how a level background of the given layer must be displayed when green swap is enabled.

Parameters
green_swap_mode
layer_identifier identifier of the layer to set the mode to.

bool ldtk::level_bgs_ptr::visible(gen::layer_ident layer_identifier) const

Indicates if a level background with the given layer must be committed to the GBA or not.

Parameters
layer_identifier identifier of the layer to get the flag from.

void ldtk::level_bgs_ptr::set_visible(bool visible, gen::layer_ident layer_identifier)

Sets if a level background of the given layer must be committed to the GBA or not.

Parameters
visible
layer_identifier identifier of the layer to set the flag to.

bool ldtk::level_bgs_ptr::visible_in_window(const bn::window& window, gen::layer_ident layer_identifier) const

Indicates if a level background with the given layer is visible in the given window or not.

Parameters
window
layer_identifier identifier of the layer to get the flag from.

void ldtk::level_bgs_ptr::set_visible_in_window(bool visible, bn::window& window, gen::layer_ident layer_identifier)

Sets if a level background of the given layer must be visible in the given window or not.

Parameters
visible
window
layer_identifier identifier of the layer to set the flag to.

tile_grid_base::tile_info ldtk::level_bgs_ptr::out_of_bound_tile_info(gen::layer_ident layer_identifier) const

Returns the tile info that fills the out-of-bound region of a level background.

Parameters
layer_identifier identifier of the layer to get the tile info from.

void ldtk::level_bgs_ptr::set_out_of_bound_tile_info(tile_grid_base::tile_info oob_tile_info, gen::layer_ident layer_identifier)

Sets the tile info that fills the out-of-bound region of a level background.

Parameters
oob_tile_info tile info to fill the out-of-bound region of a level background.
layer_identifier identifier of the layer to set the tile info to.

void ldtk::level_bgs_ptr::swap(level_bgs_ptr& other) noexcept

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

Parameters
other level_bgs_ptr to exchange the contents with.

void swap(level_bgs_ptr& a, level_bgs_ptr& b) noexcept

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

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