ldtk::level class

Public functions

auto get_layer(gen::layer_ident identifier) const -> const layer& constexpr
Looks up a layer with its identifier.
auto find_layer(gen::layer_iid iid) const -> const layer& constexpr
Linear searches a layer with its Instance id.
auto get_field(gen::level_field_ident identifier) const -> const field& constexpr
Looks up a field with its identifier.
auto create_bgs() const -> level_bgs_ptr
Creates a level_bgs_ptr using the information contained in this level.
auto create_bgs(bn::fixed x, bn::fixed y) const -> level_bgs_ptr
Creates a level_bgs_ptr using the information contained in this level.
auto create_bgs(const bn::fixed_point& position) const -> level_bgs_ptr
Creates a level_bgs_ptr using the information contained in this level.
auto bg_color() const -> bn::color constexpr
Background color of the level.
auto field_instances() const -> const bn::span<const field>& constexpr
An array containing this level custom field values.
auto identifier() const -> gen::level_ident constexpr
User defined unique identifier.
auto iid() const -> gen::level_iid constexpr
Unique level instance id.
auto layer_instances() const -> const bn::span<const layer>& constexpr
An array containing all Layer instances.
auto px_size() const -> const bn::size& constexpr
Size of the level in pixels.
auto px_width() const -> int constexpr
Width of the level in pixels.
auto px_height() const -> int constexpr
Height of the level in pixels.
auto uid() const -> int constexpr
Unique Int identifier.
auto world_depth() const -> int constexpr
Index that represents the "depth" of the level in the world. Default is 0, greater means "above", lower means "below".
This value is mostly used for display only and is intended to make stacking of levels easier to manage.
auto world_coord() const -> const bn::point& constexpr
World coordinate in pixels.
Only relevant for world layouts where level spatial positioning is manual (ie. GridVania, Free). For Horizontal and Vertical layouts, the value is always -1 here.
auto world_x() const -> int constexpr
World X coordinate in pixels.
Only relevant for world layouts where level spatial positioning is manual (ie. GridVania, Free). For Horizontal and Vertical layouts, the value is always -1 here.
auto world_y() const -> int constexpr
World Y coordinate in pixels.
Only relevant for world layouts where level spatial positioning is manual (ie. GridVania, Free). For Horizontal and Vertical layouts, the value is always -1 here.

Function documentation

const layer& ldtk::level::get_layer(gen::layer_ident identifier) const constexpr

Looks up a layer with its identifier.

Parameters
identifier Unique identifier of the layer to search for.
Returns Reference to the layer.

const layer& ldtk::level::find_layer(gen::layer_iid iid) const constexpr

Linear searches a layer with its Instance id.

Parameters
iid Instance id of the layer to search for.
Returns Reference to the found layer.

const field& ldtk::level::get_field(gen::level_field_ident identifier) const constexpr

Looks up a field with its identifier.

Parameters
identifier Unique identifier of the field to look up.
Returns Reference to the field.

level_bgs_ptr ldtk::level::create_bgs() const

Creates a level_bgs_ptr using the information contained in this level.

Returns The requested level_bgs_ptr.

level_bgs_ptr ldtk::level::create_bgs(bn::fixed x, bn::fixed y) const

Creates a level_bgs_ptr using the information contained in this level.

Parameters
x Horizontal position of the level backgrounds.
y Vertical position of the level backgrounds.
Returns The requested level_bgs_ptr.

level_bgs_ptr ldtk::level::create_bgs(const bn::fixed_point& position) const

Creates a level_bgs_ptr using the information contained in this level.

Parameters
position Position of the level backgrounds.
Returns The requested level_bgs_ptr.

const bn::span<const layer>& ldtk::level::layer_instances() const constexpr

An array containing all Layer instances.