Optional
Beta
charSets 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
.
Optional
collidesSet to false, if character should not collide (neither with the tilemap, nor with other characters). For more control, pass a CollisionConfig object.
Optional
containerA 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.
Optional
depthA custom y-offset for the sprite/container depth. In GridEngine the depth sorting of characters depends on their character layer and on their y pixel position. By setting a depthOffset you can change the y pixel position for the depth sorting without changing the actual y pixel position.
For example: Consider two characters A and B that are on the same character
layer. If char A is on y pixel position 100 and char B is on y pixel
position 120, then char B would be rendered in front of char A. If you set
depthOffset = -50
for char B then char A would be rendered on top of char
B instead (because the depth relevant y pos of char B is 120 - 50 = 80 and
that of char A is 100).
Optional
facingSets the direction the character is initially facing.
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.
Optional
labelsSets labels for the character. They can be used to filter and logically group characters.
Optional
numberThe 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.
Optional
offsetXA custom x-offset for the sprite/container.
Optional
offsetYA custom y-offset for the sprite/container.
Optional
speedThe speed of a player in tiles per second.
Optional
spriteThe character’s sprite.
Optional
startStart tile position of the player.
Optional
tileHeight of the character in tiles. This allows to specify character that span more than just one tile.
Optional
tileWith of the character in tiles. This allows to specify character that span more than just one tile.
Optional
walkingIf 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.
Configuration object used to initialize a new character in GridEngine.