Class TiledSceneMap

  • All Implemented Interfaces:
    SceneMap

    public final class TiledSceneMap
    extends java.lang.Object
    implements SceneMap
    Map created with the Tiled map editor (https://https://www.mapeditor.org).

    Recognizes three special layers:

    • **actors** - object layer with objects defining name, type and rectangle (starting position) of an Actor.
    • **markers** - object layer with objects defining name and rectangle of markers in the scene.
    • **walls** - tile layer, in which filled tiles define walls in the scene.
    • Field Detail

      • ACTORS_LAYER_NAME

        @NotNull
        public static final @NotNull java.lang.String ACTORS_LAYER_NAME
        See Also:
        Constant Field Values
      • MARKERS_LAYER_NAME

        @NotNull
        public static final @NotNull java.lang.String MARKERS_LAYER_NAME
        See Also:
        Constant Field Values
      • WALLS_LAYER_NAME

        @NotNull
        public static final @NotNull java.lang.String WALLS_LAYER_NAME
        See Also:
        Constant Field Values
    • Constructor Detail

      • TiledSceneMap

        public TiledSceneMap​(@NotNull
                             @NotNull java.lang.String mapResource,
                             @NotNull
                             @NotNull Scene scene)
    • Method Detail

      • getMapResource

        @NotNull
        public @NotNull java.lang.String getMapResource()
      • getGridWidth

        public int getGridWidth()
        Specified by:
        getGridWidth in interface SceneMap
        Returns:
        width of the map tile grid (unit: tile)
      • getGridHeight

        public int getGridHeight()
        Specified by:
        getGridHeight in interface SceneMap
        Returns:
        height of the map tile grid (unit: tile)
      • getTileWidth

        public int getTileWidth()
        Specified by:
        getTileWidth in interface SceneMap
        Returns:
        width of a single tile (unit: pixel)
      • getTileHeight

        public int getTileHeight()
        Specified by:
        getTileHeight in interface SceneMap
        Returns:
        height of a single tile (unit: pixel)
      • getOverlay

        @NotNull
        public @NotNull Overlay getOverlay()
        Specified by:
        getOverlay in interface SceneMap
        Returns:
        map overlay layer
      • getTile

        @NotNull
        public @NotNull MapTile getTile​(int tileX,
                                        int tileY)
        Description copied from interface: SceneMap
        Gets a tile at specified grid position.
        Specified by:
        getTile in interface SceneMap
        Parameters:
        tileX - x position of the tile in grid
        tileY - y position of the tile in grid
        Returns:
        tile at specified grid position
      • intersectsWithWall

        public boolean intersectsWithWall​(@NotNull
                                          @NotNull Actor actor)
        Specified by:
        intersectsWithWall in interface SceneMap
        Parameters:
        actor - actor to check for intersection
        Returns:
        true if the specified actor intersects with a wall in the map
      • render

        public void render​(float deltaTime)
        Description copied from interface: SceneMap
        Renders the map.
        Specified by:
        render in interface SceneMap
        Parameters:
        deltaTime - time passed from since the previous render