Skip to content

Project

Modar Nasser edited this page Jun 19, 2024 · 10 revisions

In file LDtkLoader/Project.hpp

Class : ldtk::Project

A Project represents the whole LDtk project file and can contain one or multiple worlds.

Constructor

ldtk::Project::Project()

Default constructor.

Methods

loadFromFile

ldtk::Project::LoadFromFile(const std::string& filepath)

Load a LDtk project from a given file path.

After this method is executed, everything will be loaded in the Project object.

Throws an exception in case of failure.


ldtk::Project::loadFromFile(const std::string& filepath, const FileLoader& file_loader)

This overload allows loading a LDtk project using a custom stream.

This allows for example, to load a file from a virtual filesystem.

See FileLoader.

🔝

loadFromMemory

ldtk::Project::loadFromMemory(const std::vector<std::uint8_t>& bytes)
ldtk::Project::loadFromMemory(const unsigned char* data, size_t size)

Load a LDtk project from a string in memory.

🔝

getFilePath

ldtk::Project::getFilePath() const -> const ldtk::FilePath&

Returns the path of the file from which the Project was loaded.

🔝

getDefaultPivot

ldtk::Project::getDefaultPivot() const -> const ldtk::FloatPoint&

Returns the default pivot, a point from (0.f, 0.f) to (1.f, 1.f).

🔝

getDefaultCellSize

ldtk::Project::getDefaultCellSize() const -> int

Returns the default size of a cell in the Project's world grid.

Cell dimension is (size, size).

🔝

getBgColor

ldtk::Project::getBgColor() const -> const ldtk::Color&

Returns the default background color of the Project.

🔝

allTilesets

ldtk::Project::allTilesets() const -> const std::vector<ldtk::Tileset>&

Returns a vector containing all the Tilesets of the Project.

🔝

getTileset

ldtk::Project::getTileset(int id) const -> const ldtk::Tileset&
ldtk::Project::getTileset(const std::string& name) const -> const ldtk::Tileset&

Returns the Tileset matching the given id or name.

If no Tileset is found, an invalid_argument exception is thrown.

🔝

allWorlds

ldtk::Project::allWorlds() const -> const std::vector<ldtk::Project>&

Returns a vector containing all the Worlds of the Project.

🔝

getWorld

ldtk::Project::getWorld() const -> const ldtk::Project&

For Projects with only one world, returns the World.

If the project has multiple worlds, an invalid_argument exception is thrown.


ldtk::Project::getWorld(const std::string& name) const -> const ldtk::Project&

For projects with multi-worlds enabled, returns the World matching the given name.

If no World is found, an invalid_argument exception is thrown.

🔝

getEnum

ldtk::Project::getEnum(int id) const -> const ldtk::Enum&
ldtk::Project::getEnum(const std::string& name) const -> const ldtk::Enum&

Returns the Enum matching the given id or name.

If no Enum is found, an invalid_argument exception is thrown.

🔝

getLayerDef

ldtk::Project::getLayerDef(int id) const -> const ldtk::LayerDef&
ldtk::Project::getLayerDef(const std::string& name) const -> const ldtk::LayerDef&

Returns the LayerDef matching the given id or name.

If no LayerDef is found, an invalid_argument exception is thrown.

🔝

getEntityDef

ldtk::Project::getEntityDef(int id) const -> const ldtk::EntityDef&
ldtk::Project::getEntityDef(const std::string& name) const -> const ldtk::EntityDef&

Returns the EntityDef matching the given id or name.

If no EntityDef is found, an invalid_argument exception is thrown.

🔝

allTocEntities

ldtk::Project::allTocEntities() const -> const std::vector<EntityRef>&

Returns a vector containing the EntityRefs that are located in the ToC.

🔝

getTocEntitiesByName

ldtk::Project::getTocEntitiesByName(const std::string& name) const -> const std::vector<EntityRef>&

Returns a vector containing the EntityRefs with the given name, that are located in the ToC.

🔝

Clone this wiki locally