Interface CharacterData

Configuration object used to initialize a new character in GridEngine.

Hierarchy

Properties

charLayer?: string

Sets the character layer of the character. If omitted the lowest character layer of the tilemap is taken. If there are no character layers in the tilemap, it will get the char layer undefined.

collides?: boolean | CollisionConfig

Set to false, if character should not collide (neither with the tilemap, nor with other characters). For more control, pass a CollisionConfig object.

Default Value

true

container?: Container

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.

If you pass both, a container and a sprite, only the container's pixel position will be changed on movement. That is only relevant if you pass a sprite that is not included in the container.

The height of the container is needed for depth sorting. Because calculating the container height is an expensive operation, it will be cached in Grid Engine. If you change the height of the container, make sure to set it to for character again to refresh the cached height.

For more details see the container example.

facingDirection?: Direction

Sets the direction the character is initially facing.

Default Value

DOWN

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.

labels?: string[]

Sets labels for the character. They can be used to filter and logically group characters.

Default Value

[]

numberOfDirections?: NumberOfDirections

The possible number of directions for moving a character. This setting can be used to override the global setting in the GridEngine configuration for specific characters.

offsetX?: number

A custom x-offset for the sprite/container.

Default Value

0

offsetY?: number

A custom y-offset for the sprite/container.

Default Value

0

speed?: number

The speed of a player in tiles per second.

Default Value

4

sprite?: Sprite

The character’s sprite.

startPosition?: Position

Start tile position of the player.

Default Value

{x: 0, y:0}

tileHeight?: number

Height of the character in tiles. This allows to specify character that span more than just one tile.

Default Value

1

tileWidth?: number

With of the character in tiles. This allows to specify character that span more than just one tile.

Default Value

1

walkingAnimationMapping?: number | WalkingAnimationMapping

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. 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.

For more details see the custom walking animation mapping example.

Generated using TypeDoc