Options
All
  • Public
  • Public/Protected
  • All
Menu

A wrapper around NavMesh for Phaser 3. Create instances of this class from PhaserNavMeshPlugin. This is the workhorse that represents a navigation mesh built from a series of polygons. Once built, the mesh can be asked for a path from one point to another point.

Compared to NavMesh, this adds visual debugging capabilities and converts paths to Phaser-compatible point instances.

export

Hierarchy

  • PhaserNavMesh

Index

Constructors

constructor

  • Creates an instance of PhaserNavMesh.

    Parameters

    • plugin: PhaserNavMeshPlugin

      The plugin that owns this mesh.

    • scene: Scene
    • key: string

      The key the mesh is stored under within the plugin.

    • meshPolygonPoints: PolyPoints[]

      Array where each element is an array of point-like objects that defines a polygon.

    • meshShrinkAmount: number = 0

      The amount (in pixels) that the navmesh has been shrunk around obstacles (a.k.a the amount obstacles have been expanded)

    Returns PhaserNavMesh

Properties

Private debugGraphics

debugGraphics: null | Graphics

Private key

key: string

Private navMesh

navMesh: NavMesh

Private plugin

Private scene

scene: Scene

Methods

debugDrawClear

  • debugDrawClear(): void

debugDrawMesh

  • debugDrawMesh(__namedParameters?: { drawBounds: any; drawCentroid: any; drawNeighbors: any; drawPortals: any; palette: any }): void
  • Visualize the polygons in the navmesh by drawing them to the debug graphics.

    Parameters

    • __namedParameters: { drawBounds: any; drawCentroid: any; drawNeighbors: any; drawPortals: any; palette: any } = {}

    Returns void

debugDrawPath

  • debugDrawPath(path: Point[], color?: number, thickness?: number, alpha?: number): void
  • Visualize a path (array of points) on the debug graphics.

    Parameters

    • path: Point[]

      Array of point-like objects in the form {x, y}

    • color: number = 0x00ff00
    • thickness: number = 10
    • alpha: number = 1

    Returns void

destroy

  • destroy(): void

disableDebug

  • disableDebug(): void

enableDebug

  • enableDebug(graphics: Graphics): null | Graphics
  • Enable the debug drawing graphics. If no graphics object is provided, a new instance will be created.

    Parameters

    • graphics: Graphics

      An optional graphics object for the mesh to use for debug drawing. Note, the mesh will destroy this graphics object when the mesh is destroyed.

    Returns null | Graphics

    The graphics object this mesh uses.

findPath

  • findPath(startPoint: Point, endPoint: Point, PointClass?: typeof Point): null | Point[]
  • See {@link NavMesh#findPath}. This implements the same functionality, except that the returned path is converted to Phaser-compatible points.

    Parameters

    • startPoint: Point

      A point-like object

    • endPoint: Point

      A point-like object

    • PointClass: typeof Point = ...

      The class used to represent points in the final path

    Returns null | Point[]

    An array of points if a path is found, or null if no path

isDebugEnabled

  • isDebugEnabled(): null | boolean

isPointInMesh

  • isPointInMesh(point: Point): boolean

Generated using TypeDoc