Skip to content

DataTypes

Modar Nasser edited this page Dec 14, 2024 · 8 revisions

In file LDtkLoader/DataTypes.hpp

Class : ldtk::FilePath

A string that contains file path information.

Constructor

ldtk::FilePath::FilePath()

Default constructor. Constructs an empty FilePath.

ldtk::FilePath::FilePath(const std::string&)

Construct a FilePath from a valid provided string.

Methods

directory

ldtk::FilePath::directory() const -> std::string

Returns the path to the directory containing the file.

filename

ldtk::FilePath::filename() const -> std::string

Returns the filename (including the extension) of the FilePath.

extension

ldtk::FilePath::extension() const -> std::string

Returns only the extension of the file (e.g. png, json, txt ...).

🔝

Struct : ldtk::Point<T>

Represents a two dimentional coordinate.

T can be one of the following types: float, int or unsigned int.

Aliases:

  • ldtk::FloatPoint = ldtk::Point<float>
  • ldtk::IntPoint = ldtk::Point<int>
  • ldtk::UIntPoint = ldtk::Point<unsigned int>

Fields

x

T ldtk::Point<T>::x

X coordinate of the Point.

y

T ldtk::Point<T>::y

Y coordinate of the Point.

🔝

Struct : ldtk::Rect<T>

Represents an axis aligned rectangle.

T can be one of the following types: float or int.

Aliases:

  • ldtk::FloatRect = ldtk::Rect<float>
  • ldtk::IntRect = ldtk::Rect<int>

Fields

x

T ldtk::Rect<T>::x

X coordinate of the top left corner of the Rect.

y

T ldtk::Rect<T>::y

Y coordinate of the top left corner of the Rect.

width

T ldtk::Rect<T>::width

Width of the Rect.

height

T ldtk::Rect<T>::height

Height of the Rect.

🔝

Struct : ldtk::Color

Represents a color value in the 32 bits RGBA format.

Fields

r

std::uint8_t ldtk::Color::r

Red component of the Color.

g

std::uint8_t ldtk::Color::g

Green component of the Color.

b

std::uint8_t ldtk::Color::n

Blue component of the Color.

a

std::uint8_t ldtk::Color::a

Alpha component of the Color (opacity).

🔝

Struct : ldtk::EntityRef

Represents a reference to an Entity.

Methods

operator->

ldtk::EntityRef::operator->() const -> const ldtk::Entity*

Returns a pointer to the Entity referenced by the EntityRef.

This operator allows to access the Entity reference like this:

entity_ref->getName(); // returns the name of the referenced Entity

🔝

Struct : ldtk::TileRect

Represents a rectangle of one or multiple tiles. Used in TileField.

Fields

bounds

const IntRect ldtk::TileRect::bounds

🔝

Methods

getTileset

ldtk::TileRect::getTileset() const -> const Tileset&

Returns the Tileset to which the tile belongs.

🔝

Struct : ldtk::NineSliceBorders

Represents the dimensions of the 9-slice tile render.

Fields

top

int ldtk::NineSliceBorders::top

right

int ldtk::NineSliceBorders::right

bottom

int ldtk::NineSliceBorders::bottom

left

int ldtk::NineSliceBorders::left

🔝

Struct : ldtk::IntGridValue

Represents the grid values that can be painted on an IntGrid layer.

Fields

value

const int ldtk::IntGridValue::value

name

const std::string ldtk::IntGridValue::name

color

const ldtk::Color ldtk::IntGridValue::color

🔝

Struct : ldtk::Vertex

Represents a vertex composed of a position and a texture coordinate.

The graphic representation of a Tile is composed of 4 vertices.

Fields

pos

const ldtk::FloatPoint ldtk::Vertex::pos

Coordinate of the vertex in pixels, relative to the Level.

tex

const ldtk::IntPoint ldtk::Vertex::tex

Texture coordinate of the vertex, in pixels.

🔝

Enum : ldtk::WorldLayout

Contains enum values representing all the possible types of World layouts.

  1. WorldLayout::Free
  2. WorldLayout::GridVania
  3. WorldLayout::LinearHorizontal
  4. WorldLayout::LinearVertical

🔝

Enum : ldtk::LayerType

Contains enum values representing all the possible types of Layers.

  1. LayerType::IntGrid
  2. LayerType::Entities
  3. LayerType::Tiles
  4. LayerType::AutoLayer

🔝

Enum : ldtk::FieldType

Contains enum values representing all the possible types of a Field.

These enum values can be used to get a field from an Entity. For example:

const auto& field_value = entity.getField<ldtk::FieldType::ArrayEntityRef>();
// The type of field_value is ldtk::ArrayField<ldtk::EntityRef>
  1. FieldType::Int
  2. FieldType::Float
  3. FieldType::Bool
  4. FieldType::String
  5. FieldType::Color
  6. FieldType::Point
  7. FieldType::Enum
  8. FieldType::FilePath
  9. FieldType::Tile
  10. FieldType::EntityRef
  11. FieldType::ArrayInt
  12. FieldType::ArrayFloat
  13. FieldType::ArrayBool
  14. FieldType::ArrayString
  15. FieldType::ArrayColor
  16. FieldType::ArrayPoint
  17. FieldType::ArrayEnum
  18. FieldType::ArrayFilePath
  19. FieldType::ArrayTile
  20. FieldType::ArrayEntityRef

🔝

Enum : ldtk::Dir

Contains enum values representing all the possible Directions of Level neighbours.

It is used by ldtk::Level::getNeighbours(const ldtk::Dir&) and returned by ldtk::getNeighbourDirection(const Level&).

  1. Dir::None
  2. Dir::North
  3. Dir::NorthEast
  4. Dir::East
  5. Dir::SouthEast
  6. Dir::South
  7. Dir::SouthWest
  8. Dir::West
  9. Dir::NorthWest

🔝

Type : ldtk::FileLoader

using ldtk::FileLoader = std::function<std::unique_ptr<std::streambuf>(const std::string&)>

FileLoader is the type of a function that takes the path of a file as parameter and returns a unique pointer to a standard stream buffer for that file.

This allows to load a Project from a custom source stream (e.g. from a virtual filesystem).

🔝

Clone this wiki locally