Options
All
  • Public
  • Public/Protected
  • All
Menu

A wrapper around NavMesh for Phaser 2 / Phaser CE. Create instances of this class from Phaser2NavMeshPlugin. 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.

Hierarchy

  • Phaser2NavMesh

Index

Constructors

constructor

Properties

Private debugGraphics

debugGraphics: null | Graphics

Private game

game: Game

Private key

key: string

Private navMesh

navMesh: NavMesh

Private plugin

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

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 in the form {x, y}

    • endPoint: Point

      A point-like object in the form {x, y}

    • PointClass: typeof Point = ...

      The point class to use to represent points in the 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