Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: AStarPathfinder

[14:7] extends: FxObj

Wraps FXGL's AStarPathfinder, the A* algorithm that computes walkable paths through an AStarGrid. Construct with the grid, then call findPath(sx, sy, tx, ty) to get the ordered list of AStarCells from source to target (excluding the source).

Methods

  • AStarPathfinder (object Grid)

    Creates a pathfinder bound to the given AStarGrid.

    • @p Grid is an AStarGrid wrapper.
  • findPath (int Sx, int Sy, int Tx, int Ty)

    Finds an A* path from (Sx, Sy) to (Tx, Ty). Returns an empty list if no path exists.

    • @p Sx is the source column.
    • @p Sy is the source row.
    • @p Tx is the target column.
    • @p Ty is the target row.
    • @r A list of AStarCell wrappers forming the path (target last).
  • findPathDir (int Sx, int Sy, int Tx, int Ty, string DirectionName)

    Finds an A* path using the given NeighborDirection (4- or 8-directional).

    • @p Sx is the source column.
    • @p Sy is the source row.
    • @p Tx is the target column.
    • @p Ty is the target row.
    • @p DirectionName is "FOUR_DIRECTIONS" or "EIGHT_DIRECTIONS".
    • @r A list of AStarCell wrappers.
  • findPathBusy (int Sx, int Sy, int Tx, int Ty, list BusyCells)

    Finds an A* path treating the given cells as occupied (useful for routing around the current positions of other units).

    • @p Sx is the source column.
    • @p Sy is the source row.
    • @p Tx is the target column.
    • @p Ty is the target row.
    • @p BusyCells is a list of AStarCell wrappers to avoid.
    • @r A list of AStarCell wrappers.
  • findPathDirBusy (int Sx, int Sy, int Tx, int Ty, string DirectionName, list BusyCells)

    Finds an A* path with both NeighborDirection and busy cells.

    • @p Sx is the source column.
    • @p Sy is the source row.
    • @p Tx is the target column.
    • @p Ty is the target row.
    • @p DirectionName is "FOUR_DIRECTIONS" or "EIGHT_DIRECTIONS".
    • @p BusyCells is a list of AStarCell wrappers to avoid.
    • @r A list of AStarCell wrappers.
  • setCachingPaths (bool Enabled)

    Enables or disables path caching. With caching on, repeated findPath calls for the same source/target return cached results.

    • @p Enabled is a bool.
    • @r this object
  • isCachingPaths ()

    Returns whether path caching is currently enabled.

    • @r A bool.
  • getGrid ()

    Returns the underlying TraversableGrid AJO (the same grid passed to the constructor).

    • @r A raw AussomJavaObject around the TraversableGrid.
  • withHeuristics (object Grid, object DefaultHeuristic, object DiagonalHeuristicObj)

    Builds an AStarPathfinder over the given grid with custom default + diagonal heuristics. Returns a new wrapper.

    • @p Grid is an AStarGrid (or other TraversableGrid) wrapper.
    • @p DefaultHeuristic is a Heuristic wrapper used in 4-direction mode.
    • @p DiagonalHeuristicObj is a DiagonalHeuristic wrapper used in 8-direction mode.
    • @r A new AStarPathfinder wrapper.
  • _toCellList (javaList)