Options
All
  • Public
  • Public/Protected
  • All
Menu

This class can create navigation meshes for use in Phaser 2 / Phaser CE. (For Phaser 3, see PhaserNavMeshPlugin.) The navmeshes can be constructed from convex polygons embedded in a Tiled map. The class that conforms to Phaser 2's plugin structure.

Hierarchy

  • Plugin
    • Phaser2NavMeshPlugin

Index

Constructors

constructor

Properties

active

active: boolean

A Plugin with active=true has its preUpdate and update methods called by the parent, otherwise they are skipped.

game

game: Game

A reference to the currently running game.

hasPostRender

hasPostRender: boolean

A flag to indicate if this plugin has a postRender method.

hasPostUpdate

hasPostUpdate: boolean

A flag to indicate if this plugin has a postUpdate method.

hasPreUpdate

hasPreUpdate: boolean

A flag to indicate if this plugin has a preUpdate method.

hasRender

hasRender: boolean

A flag to indicate if this plugin has a render method.

hasUpdate

hasUpdate: boolean

A flag to indicate if this plugin has an update method.

parent

parent: DisplayObject

The parent of this plugin. If added to the PluginManager the parent will be set to that, otherwise it will be null.

Private phaserNavMeshes

phaserNavMeshes: Record<string, Phaser2NavMesh> = {}

visible

visible: boolean

A Plugin with visible=true has its render and postRender methods called by the parent, otherwise they are skipped.

Methods

buildMeshFromTiled

  • buildMeshFromTiled(key: string, objectLayer: any[], meshShrinkAmount?: number): Phaser2NavMesh
  • Load a navmesh from Tiled. Currently assumes that the polygons are squares! Does not support tilemap layer scaling, rotation or position.

    Parameters

    • key: string

      Key to use when storing this navmesh within the plugin.

    • objectLayer: any[]

      The ObjectLayer from a tilemap that contains the polygons that make up the navmesh.

    • meshShrinkAmount: number = 0

    Returns Phaser2NavMesh

destroy

  • destroy(): void

postRender

  • postRender(): void
  • Post-render is called after the Game Renderer and State.render have run. It is only called if visible is set to true.

    Returns void

preUpdate

  • preUpdate(): void
  • Pre-update is called at the very start of the update cycle, before any other subsystems have been updated (including Physics). It is only called if active is set to true.

    Returns void

removeAllMeshes

  • removeAllMeshes(): void

removeMesh

  • removeMesh(key: string): void

render

  • render(): void
  • Render is called right after the Game Renderer completes, but before the State.render. It is only called if visible is set to true.

    Returns void

update

  • update(): void
  • Update is called after all the core subsystems (Input, Tweens, Sound, etc) and the State have updated, but before the render. It is only called if active is set to true.

    Returns void

Generated using TypeDoc