Link Search Menu Expand Document

Config

The data shape of the configuration object is described here.

GridEngineConfig

characters: CharacterData[]
An array of character data. Each describing a character on the map.
collisionTilePropertyName: string OPTIONAL
A custom name for the collision tile property of your tilemap.
numberOfDirections: 4 | 8 OPTIONALDEFAULT: 4
The possible number of directions for moving a character. Default is 4 (up, down, left, right). If set to 8 it additionaly enables diagonal movement (up-left, up-right, down-left, down-right).
characterCollisionStrategy: CollisionStrategy OPTIONALDEFAULT: “BLOCK_TWO_TILES”
The character collision strategy. See CollisionStrategy.

CharacterData

id: string
A unique identifier for the character on the map. If you provice two characters with the same id, the last one will override the previous one.
sprite: Phaser.GameObjects.Sprite
The character’s sprite.
walkingAnimationMapping: number | WalkingAnimationMapping OPTIONAL
If not set, automatic walking animation will be disabed. Do this if you want to use a custom animation. In case of number: The 0-based index of the character on the spritesheet. Here is an example image showing the character indices: Example of a height shift. In case of WalkingAnimationMapping: Alternatively to providing a characterIndex you can also provide a custom frame mapping. This is especially handy if your spritesheet has a different arrangement of frames than you can see in the example image (4 rows with 3 columns). You can provide the frame number for every state of the character. If both, a characterIndex and a walkingAnimationMapping is set, the walkingAnimationMapping is given preference. For more details see the custom walking animation mapping example
speed: TileSizePerSecond OPTIONALDEFAULT: 4
The speed of a player in tiles per second.
startPosition: Position OPTIONALDEFAULT: (0, 0)
Start tile position of the player.
container: Phaser.GameObjects.Container OPTIONAL
A container that holds the character’s sprite. This can be used in order to move more game objects along with the sprite (for example a character’s name or health bar). In order to position the container correctly on the tiles, it is necessary that you position the character’s sprite on position (0, 0) in the container. For more details see the container example
offsetX: number OPTIONAL
A custom x-offset for the sprite/container. For more details see the custom offset example
offsetY: number OPTIONAL
A custom y-offset for the sprite/container. For more details see the custom offset example
facingDirection: Direction OPTIONAL
Sets the direction the character is initially facing.

WalkingAnimationMapping

{
  up: {
    leftFoot: number,
    standing: number,
    rightFoot: number
  },
  right: {
    leftFoot: number,
    standing: number,
    rightFoot: number
  },
  down: {
    leftFoot: number,
    standing: number,
    rightFoot: number
  },
  left: {
    leftFoot: number,
    standing: number,
    rightFoot: number
  }
}

Direction

"none" | "up" | "right" | "left" | "down" | "up-left" | "up-right" | "down-left" | "down-right"

Position

{
  x: number,
  y: number
}

CollisionStrategy

"BLOCK_TWO_TILES" | "BLOCK_ONE_TILE_AHEAD",

“BLOCK_TWO_TILES”: When character is standing, it will block only one tile. If it is moving, it will block the tile it is leaving and the tile it is entering

“BLOCK_ONE_TILE_AHEAD”: When character is standing, it will block only one tile. If it is moving, it will only block the tile it is entering.