On this page
  1. name
  2. type
  3. iid
  4. position
  5. size
  6. rotation
  7. gid
  8. property_bool, property_int, property_float
  9. property_string
  10. property_point, property_count

rmp::MapObject

struct #include <rmp/tilemap.h> include/rmp/tilemap.h:89
struct MapObject

One object placed in the map, as spawn_objects() hands it to the factory registered for its type: where it is, how big, and its properties.

name

std::string_view name

The Tiled object's name; "" for an LDtk entity

type

std::string_view type

The LDtk entity; Tiled's class

iid

std::string_view iid

LDtk's unique id, what an EntityRef field holds

position

Vector2 position{}

THE CENTRE, like rmp::Object; the editors give a corner

size

Vector2 size{}

Width and height in world units; {0,0} for a Tiled point

rotation

float rotation = 0

Tiled's, in degrees clockwise; 0 for an LDtk entity

gid

int gid = 0

0 when it is not a tile object

property_bool, property_int, property_float

bool property_bool(std::string_view key, bool fallback = false) const
int property_int(std::string_view key, int fallback = 0) const
float property_float(std::string_view key, float fallback = 0) const

A property by name — an LDtk field, a Tiled custom property — or fallback when the object has none by that name or it holds another kind. property_int() also reads a float, cut towards zero, and property_float() also reads an int.

property_string

std::string_view property_string(std::string_view key, std::string_view fallback = "") const

The map's text, or fallback as it was given: its lifetime is yours.

property_point, property_count

Vector2 property_point(std::string_view key, Vector2 fallback = {}) const
Vector2 property_point(std::string_view key, int index, Vector2 fallback = {}) const
int property_count(std::string_view key) const

An LDtk Point field, as the WORLD position of the centre of the cell it names — the same units as position, so a patrol route or a platform's destination is used as it comes. A list of them (Array<Point>) is read by index; property_count() is how many there are, and 1 for any other field that exists. Enums read as text, colours as "#rrggbb", and an EntityRef as the iid of the entity it points at.