Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: AStarGrid

[14:7] extends: TraversableGrid

Wraps FXGL's AStarGrid, the default AStarCell-typed grid used by AStarPathfinder. All cells start WALKABLE; mark obstacles by calling get(x, y).setState("NOT_WALKABLE") before searching.

Methods

  • AStarGrid (int Width, int Height)

    Creates a new AStarGrid of the given dimensions with all cells WALKABLE.

    • @p Width is the column count.
    • @p Height is the row count.
  • adopt (object Ajo)

    Wraps an existing AStarGrid AussomJavaObject.

    • @p Ajo is an AussomJavaObject around an AStarGrid.
    • @r A new wrapper.
  • getWidth ()

    Returns the grid width.

    • @r An int.
  • getHeight ()

    Returns the grid height.

    • @r An int.
  • get (int X, int Y)

    Returns the AStarCell at (X, Y).

    • @p X is the column.
    • @p Y is the row.
    • @r An AStarCell wrapper.
  • isWithin (int X, int Y)

    Returns whether (X, Y) is inside the grid.

    • @p X is the column.
    • @p Y is the row.
    • @r A bool.
  • _cellList (javaList)

  • getCells ()

    Returns every cell in the grid.

    • @r A list of AStarCell wrappers.
  • getWalkableCells ()

    Returns only the walkable cells.

    • @r A list of AStarCell wrappers.
  • getNeighbors (int X, int Y, string DirectionName = "FOUR_DIRECTIONS")

    Returns the 4- or 8-neighborhood of (X, Y).

    • @p X is the column.
    • @p Y is the row.
    • @p DirectionName is "FOUR_DIRECTIONS" or "EIGHT_DIRECTIONS". Defaults to "FOUR_DIRECTIONS".
    • @r A list of AStarCell wrappers.
  • getOptional (int X, int Y)

    Returns the cell at (X, Y) safely (null when off-grid).

    • @p X is the column.
    • @p Y is the row.
    • @r An AStarCell wrapper or null.
  • fromWorld (object WorldObj, int WorldWidth, int WorldHeight, int CellWidth, int CellHeight, callback Mapping)

    Builds an AStarGrid from the entities in a GameWorld. The Mapping callback receives each entity-type (or "" for empty cells) and must return a CellState enum AJO — use CellState.get("WALKABLE") or CellState.get("NOT_WALKABLE").

    • @p WorldObj is a GameWorld wrapper.
    • @p WorldWidth is the grid width in cells.
    • @p WorldHeight is the grid height in cells.
    • @p CellWidth is the per-cell pixel width.
    • @p CellHeight is the per-cell pixel height.
    • @p Mapping is a callback (typeValue) -> CellState AJO.
    • @r A new AStarGrid wrapper.