Class MapObject

java.lang.Object
de.gurkenlabs.litiengine.environment.tilemap.xml.CustomPropertyProvider
de.gurkenlabs.litiengine.environment.tilemap.xml.MapObject
All Implemented Interfaces:
ICustomPropertyProvider, IMapObject, Resource, Comparable<Resource>
Direct Known Subclasses:
Blueprint

public class MapObject extends CustomPropertyProvider implements IMapObject
  • Constructor Details

    • MapObject

      public MapObject()
      Instantiates a new MapObject instance.
    • MapObject

      public MapObject(String type)
      Instantiates a new MapObject instance.
      Parameters:
      type - The type of this map object.
    • MapObject

      public MapObject(MapObject original)

      Instantiates a new MapObject instance by copying the specified original instance.

      This variant of the constructor will assign an entirely new ID to the newly created MapObject.

      Parameters:
      original - the MapObject we want to copy
    • MapObject

      public MapObject(MapObject original, boolean keepID)

      Instantiates a new MapObject instance by copying the specified original instance.

      This variant of the constructor lets you decide if the copy instance will get the same ID as the old MapObject or get a new ID.

      Parameters:
      original - the MapObject we want to copy
      keepID - decide if the new instance will adopt the old MapObject's ID or get a new, unique one.
    • MapObject

      public MapObject(MapObject original, int id)
      Instantiates a new MapObject instance by copying the specified original instance.
      Parameters:
      original - the MapObject we want to copy
      id - The id of this instance.
  • Method Details

    • getBounds

      public static Rectangle2D getBounds(IMapObject... objects)
    • getBounds

      public static Rectangle2D getBounds(Iterable<IMapObject> objects)
    • getGridId

      public int getGridId()
      Description copied from interface: IMapObject
      Gets the grid id.
      Specified by:
      getGridId in interface IMapObject
      Returns:
      the grid id
    • getTile

      public ITilesetEntry getTile()
      Description copied from interface: IMapObject
      Gets the tileset entry referenced by this map object's grid id, if any.
      Specified by:
      getTile in interface IMapObject
      Returns:
      the referenced tileset entry, or null if this object does not reference a tile
    • getBoundingBox

      public Rectangle2D getBoundingBox()
      Description copied from interface: IMapObject
      Gets the hit box.
      Specified by:
      getBoundingBox in interface IMapObject
      Returns:
      the hit box
    • getId

      public int getId()
      Description copied from interface: IMapObject
      Gets the id.
      Specified by:
      getId in interface IMapObject
      Returns:
      the id
    • getLocation

      public Point2D getLocation()
      Description copied from interface: IMapObject
      Gets the location.
      Specified by:
      getLocation in interface IMapObject
      Returns:
      the location
    • getName

      public String getName()
      Description copied from interface: Resource
      Gets the name of the resource.
      Specified by:
      getName in interface Resource
      Returns:
      The name of the resource.
    • getType

      public String getType()
      Gets the type.
      Specified by:
      getType in interface IMapObject
      Returns:
      the type
    • getPolyline

      public IPolyShape getPolyline()
      Description copied from interface: IMapObject
      Gets the polyline shape of this map object, if any.
      Specified by:
      getPolyline in interface IMapObject
      Returns:
      the polyline, or null if this object is not a polyline
    • getPolygon

      public IPolyShape getPolygon()
      Description copied from interface: IMapObject
      Gets the polygon shape of this map object, if any.
      Specified by:
      getPolygon in interface IMapObject
      Returns:
      the polygon, or null if this object is not a polygon
    • getEllipse

      public Ellipse2D getEllipse()
      Description copied from interface: IMapObject
      Gets the ellipse shape of this map object, if any.
      Specified by:
      getEllipse in interface IMapObject
      Returns:
      the ellipse, or null if this object is not an ellipse
    • getText

      public IMapObjectText getText()
      Description copied from interface: IMapObject
      Gets the text content of this map object, if it represents a text object.
      Specified by:
      getText in interface IMapObject
      Returns:
      the text content, or null if this is not a text object
    • setGridId

      public void setGridId(int gid)
      Description copied from interface: IMapObject
      Sets the grid id, i.e. the global tile id this object references.
      Specified by:
      setGridId in interface IMapObject
      Parameters:
      gid - the grid id to set
    • setHeight

      public void setHeight(float height)
      Description copied from interface: IMapObject
      Sets the height of this map object.
      Specified by:
      setHeight in interface IMapObject
      Parameters:
      height - the height to set
    • setId

      public void setId(int id)
      Description copied from interface: IMapObject
      Sets the unique id of this map object.
      Specified by:
      setId in interface IMapObject
      Parameters:
      id - the id to set
    • setName

      public void setName(String name)
      Description copied from interface: Resource
      Sets the name of the resource.
      Specified by:
      setName in interface Resource
      Parameters:
      name - The new name of the resource.
    • setType

      public void setType(String type)
      Description copied from interface: IMapObject
      Sets the user-defined type string of this map object.
      Specified by:
      setType in interface IMapObject
      Parameters:
      type - the type to set
    • setWidth

      public void setWidth(float width)
      Description copied from interface: IMapObject
      Sets the width of this map object.
      Specified by:
      setWidth in interface IMapObject
      Parameters:
      width - the width to set
    • setX

      public void setX(float x)
      Description copied from interface: IMapObject
      Sets the x coordinate of this map object.
      Specified by:
      setX in interface IMapObject
      Parameters:
      x - the x coordinate
    • setY

      public void setY(float y)
      Description copied from interface: IMapObject
      Sets the y coordinate of this map object.
      Specified by:
      setY in interface IMapObject
      Parameters:
      y - the y coordinate
    • setLocation

      public void setLocation(Point2D location)
      Description copied from interface: IMapObject
      Sets the location of this map object.
      Specified by:
      setLocation in interface IMapObject
      Parameters:
      location - the new location
    • setLocation

      public void setLocation(float x, float y)
      Description copied from interface: IMapObject
      Sets the location of this map object.
      Specified by:
      setLocation in interface IMapObject
      Parameters:
      x - the x coordinate
      y - the y coordinate
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getX

      public float getX()
      Description copied from interface: IMapObject
      Gets the x coordinate of this map object.
      Specified by:
      getX in interface IMapObject
      Returns:
      the x coordinate
    • getY

      public float getY()
      Description copied from interface: IMapObject
      Gets the y coordinate of this map object.
      Specified by:
      getY in interface IMapObject
      Returns:
      the y coordinate
    • setPolyline

      public void setPolyline(IPolyShape polyline)
      Description copied from interface: IMapObject
      Sets the polyline shape of this map object.
      Specified by:
      setPolyline in interface IMapObject
      Parameters:
      polyline - the polyline shape to set
    • setPolygon

      public void setPolygon(IPolyShape polygon)
      Description copied from interface: IMapObject
      Sets the polygon shape of this map object.
      Specified by:
      setPolygon in interface IMapObject
      Parameters:
      polygon - the polygon shape to set
    • getWidth

      public float getWidth()
      Description copied from interface: IMapObject
      Gets the width of this map object.
      Specified by:
      getWidth in interface IMapObject
      Returns:
      the width
    • getHeight

      public float getHeight()
      Description copied from interface: IMapObject
      Gets the height of this map object.
      Specified by:
      getHeight in interface IMapObject
      Returns:
      the height
    • getLayer

      public IMapObjectLayer getLayer()
      Description copied from interface: IMapObject
      Gets the layer that contains this map object.
      Specified by:
      getLayer in interface IMapObject
      Returns:
      the owning layer
    • isPolyline

      public boolean isPolyline()
      Description copied from interface: IMapObject
      Returns whether this map object is a polyline.
      Specified by:
      isPolyline in interface IMapObject
      Returns:
      true if this object is a polyline
    • isPolygon

      public boolean isPolygon()
      Description copied from interface: IMapObject
      Returns whether this map object is a polygon.
      Specified by:
      isPolygon in interface IMapObject
      Returns:
      true if this object is a polygon
    • isPoint

      public boolean isPoint()
      Description copied from interface: IMapObject
      Returns whether this map object is a single point.
      Specified by:
      isPoint in interface IMapObject
      Returns:
      true if this object is a point
    • isEllipse

      public boolean isEllipse()
      Description copied from interface: IMapObject
      Returns whether this map object is an ellipse.
      Specified by:
      isEllipse in interface IMapObject
      Returns:
      true if this object is an ellipse
    • setLayer

      protected void setLayer(MapObjectLayer layer)