grid-engine
    Preparing search index...

    Class GridEngine

    Implements

    Index

    Basic Movement

    • Returns whether the current movement has been reverted. Note that as soon as the character reaches the tile from which they started before the movement got reverted, this returns false again.

      Parameters

      • charId: string

      Returns boolean

    • Initiates movement of the character with the given id. If the character is already moving nothing happens. If the movement direction is currently blocked, the character will only turn towards that direction. Movement commands are not queued.

      Parameters

      Returns void

    • Reverts the current movement of a character. This makes the character turn around immediately and move in the opposite direction.

      Parameters

      • charId: string

      Returns void

    Character

    • Add labels to the character.

      Parameters

      • charId: string
      • labels: string[]

      Returns void

    • Returns Observable<{ charId: string; direction: Direction }>

      Observable that will notify about every change of direction that is not part of a movement. This is the case if the character tries to walk towards a blocked tile. The character will turn but not move. It also emits when you call GridEngine.turnTowards.

      This obsersable never emits more than one time in a row for the same direction. So for instance, if GridEngine.turnTowards is called multiple times in a row (without any facing direction change occurring inbetween) with the same direction, this observable would only emit once.

    • Returns the character layer of the given character. You can read more about character layers and transitions here

      Parameters

      • charId: string

      Returns undefined | string

    • Parameters

      • charId: string

      Returns undefined | Container

      Container for a character.

    • Parameters

      • charId: string

      Returns number

      depth-offset for a character.

    • Returns the movement progress (0-1000) of a character to the next tile. For example, if a character has movement progress 400 that means that it has moved 400/1000th of the distance to the next tile already.

      Parameters

      • charId: string

      Returns number

    • Parameters

      • charId: string

      Returns number

      X-offset for a character.

    • Parameters

      • charId: string

      Returns number

      Y-offset for a character.

    • Parameters

      • charId: string

      Returns undefined | Sprite

      Sprite of given character

    • Parameters

      • charId: string

      Returns boolean

      True if the character is currently moving.

    • Returns Observable<{ charId: string; direction: Direction }>

      Observable that on each stopped movement of a character will provide it’s ID and the direction of that movement.

    • Remove labels from the character.

      Parameters

      • charId: string
      • labels: string[]

      Returns void

    • Sets collision groups for the given character. Previous collision groups will be overwritten.

      Parameters

      • charId: string
      • collisionGroups: string[]

      Returns void

    • Sets the container for a character.

      Parameters

      • charId: string
      • Optionalcontainer: Container

      Returns void

    • Sets collision groups for the given character. Previous collision groups will be overwritten.

      Parameters

      • charId: string
      • ignoreCollisionGroups: string[]

      Returns void

    • Set custom x-offset for the sprite/container.

      Parameters

      • charId: string
      • offsetX: number

      Returns void

    • Set custom y-offset for the sprite/container.

      Parameters

      • charId: string
      • offsetY: number

      Returns void

    • Sets the speed in tiles per second for a character.

      Parameters

      • charId: string
      • speed: number

      Returns void

    • Sets the sprite for a character.

      Parameters

      • charId: string
      • sprite: Sprite

      Returns void

    Grid Engine

    • Checks whether a character with the given ID is registered.

      Parameters

      • charId: string

      Returns boolean

    • Removes all characters from the plugin. Please note that the corresponding sprites and containers need to be removed separately.

      Returns void

    • Removes the character with the given ID from the plugin. Please note that the corresponding sprite and container need to be removed separately.

      Parameters

      • charId: string

      Returns void

    GridEngine

    Other

    welcomeMessagePrinted: boolean = false

    Pathfinding

    • Character charId will start to walk towards charIdToFollow on a shortest path until it reaches the specified distance.

      Parameters

      • charId: string

        ID of character that should follow

      • charIdToFollow: string

        ID of character that should be followed

      • Optionaloptions: FollowOptions

      Returns void

    • Parameters

      • charId: string

        ID of character that should follow

      • charIdToFollow: string

        ID of character that should be followed

      • Optionaldistance: number

        Minimum distance to keep to charIdToFollow in manhattan distance in case of 4 direction mode and with and Chebyshev distance in case of 8 direction mode.

      • OptionalclosestPointIfBlocked: boolean

        charId will move to the closest point (manhattan distance in case of 4 direction mode and with and Chebyshev distance in case of 8 direction mode) to charIdToFollow that is reachable from charId in case that there does not exist a path between charId and charIdToFollow.

      Returns void

      Use follow(charId: string, charIdToFollow: string, options: FollowOptions): void; instead.

      Character charId will start to walk towards charIdToFollow on a shortest path until it reaches the specified distance.

    • Initiates movement toward the specified targetPos. The movement will happen along one shortest path. Check out MoveToConfig for pathfinding configurations.

      Parameters

      Returns Observable<{ charId: string } & Finished>

      an observable that will fire whenever the moveTo movement is finished or aborted. It will provide a result code as well as a description and a character layer.

    Queue Movement

    Random Movement

    • Initiates random movement of the character with the given id. The character will randomly pick one of the non-blocking directions. Optionally a delay in milliseconds can be provided. This represents the waiting time after a finished movement, before the next is being initiated. If a radius other than -1 is provided, the character will not move further than that radius from its initial position (the position it has been, when moveRandomly was called). The distance is calculated with the manhattan distance in case of 4 direction mode and with and Chebyshev distance in case of 8 direction mode. Additionally, if a radius other than -1 was given, the character might move more than one tile into a random direction in one run (as long as the route is neither blocked nor outside of the radius).

      Parameters

      • charId: string
      • delay: number = 0
      • radius: number = -1

      Returns void

    Tilemap

    • Finds the identifiers of all characters at the provided tile position.

      Parameters

      Returns string[]

      The identifiers of all characters on this tile.

    • Parameters

      Returns undefined | string

      The character layer that the transition on the given position and character layer leads to.

    • Checks whether the given position is blocked by either the tilemap or a blocking character. If you provide no layer, be sure not to use character layers in your tilemap.

      Parameters

      • position: Position
      • Optionallayer: string
      • collisionGroups: string[] = ...

      Returns boolean

      True if position on given layer is blocked by the tilemap or a character

    • Checks whether the given position is blocked by the tilemap. If you provide no layer, be sure not to use character layers in your tilemap.

      Parameters

      Returns boolean

      True if position on given layer is blocked by the tilemap.

    • Sets the character layer toLayer that the transition on position position from character layer fromLayer should lead to. You can read more about character layers and transitions here

      Parameters

      • position: Position

        Position of the new transition

      • fromLayer: string

        Character layer the new transition should start at

      • toLayer: string

        Character layer the new transition should lead to

      Returns void