Name | Type | Description |
---|---|---|
tileset |
TextureSource | TextureSource<Array> |
The tileset to use for the tilemap. This can be reset later with setTileset. The base-textures in this array must not be duplicated. |
Example
import { Tilemap } from '@pixi/tilemap';
import { Loader } from '@pixi/loaders';
// Add the spritesheet into your loader!
Loader.shared.add('atlas', 'assets/atlas.json');
// Make the tilemap once the tileset assets are available.
Loader.shared.load(function onTilesetLoaded()
{
// The base-texture is shared between all the tile textures.
const tilemap = new Tilemap([Texture.from('grass.png').baseTexture])
.tile('grass.png', 0, 0)
.tile('grass.png', 100, 100)
.tile('brick_wall.png', 0, 100);
});
Extends
- Container
Members
Currently doesnt work.
The tile animation frame.
- Default Value:
- undefined
- See:
Flags whether any animated tile was added.
- Default Value:
- false
The local bounds of the tilemap itself. This does not include DisplayObject children.
The list of base-textures being used in the tilemap.
This should not be shuffled after tiles have been added into this tilemap. Usually, only tile textures should be added after tiles have been added into the map.
Methods
Deprecated signature for tile.
Name | Type | Description |
---|---|---|
texture |
Texture | string | number | |
x |
number | |
y |
number | |
animX |
number | |
animY |
number |
Returns:
Type | Description |
---|---|
boolean |
Deprecated signature for tile.
Name | Type | Default | Description |
---|---|---|---|
textureIndex |
number | ||
u |
number | ||
v |
number | ||
x |
number | ||
y |
number | ||
tileWidth |
number | ||
tileHeight |
number | ||
animX |
number | 0 | |
animY |
number | 0 | |
rotate |
number | 0 | |
animCountX |
number | 1024 | |
animCountY |
number | 1024 | |
animDivisor |
number | 1 | |
alpha |
number | 1 |
Returns:
Type | Description |
---|---|
this |
Clears all the tiles added into this tilemap.
Returns:
Type | Description |
---|---|
this |
Name | Type | Attributes | Description |
---|---|---|---|
options |
DestroyOptions |
<optional> |
Returns:
Type | Description |
---|---|
TileTextureArray | The tileset of this tilemap. |
Define the tileset used by the tilemap.
Name | Type | Description |
---|---|---|
textureOrArray |
TileTextureArray | TextureSource | Array<TextureSource> |
The list of textures to use in the tilemap. If a base-texture (not array) is passed, it will be wrapped into an array. This should not contain any duplicates. |
Returns:
Type | Description |
---|---|
this |
Adds a tile that paints the given texture at (x, y).
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
tileTexture |
number | string | Texture | TextureSource |
The tiling texture to render. |
||
x |
number |
The local x-coordinate of the tile's position. |
||
y |
number |
The local y-coordinate of the tile's position. |
||
options |
{ u?: number, v?: number, tileWidth?: number, tileHeight?: number, animX?: number, animY?: number, rotate?: number, animCountX?: number, animCountY?: number, animDivisor?: number, alpha?: number } |
Additional tile options. |
||
options.u |
<optional> |
texture.frame.x |
The x-coordinate of the texture in its base-texture's space. |
|
options.v |
<optional> |
texture.frame.y |
The y-coordinate of the texture in its base-texture's space. |
|
options.tileWidth |
<optional> |
texture.orig.width |
The local width of the tile. |
|
options.tileHeight |
<optional> |
texture.orig.height |
The local height of the tile. |
|
options.animX |
<optional> |
0 |
For animated tiles, this is the "offset" along the x-axis for adjacent animation frame textures in the base-texture. |
|
options.animY |
<optional> |
0 |
For animated tiles, this is the "offset" along the y-axis for adjacent animation frames textures in the base-texture. |
|
options.rotate |
<optional> |
0 | ||
options.animCountX |
<optional> |
1024 |
For animated tiles, this is the number of animation frame textures per row. |
|
options.animCountY |
<optional> |
1024 |
For animated tiles, this is the number of animation frame textures per column. |
|
options.animDivisor |
<optional> |
1 |
For animated tiles, this is the animation duration of each frame |
|
options.alpha |
<optional> |
1 |
Tile alpha |
Returns:
Type | Description |
---|---|
this | This tilemap, good for chaining. |
Changes the animDivisor
value of the last tile.
Name | Type | Description |
---|---|---|
divisor |
number |
Changes the animX
, animCountX
of the last tile.
Name | Type | Description |
---|---|---|
offset |
number | |
count |
number |
Changes the animY
, animCountY
of the last tile.
Name | Type | Description |
---|---|---|
offset |
number | |
count |
number |
Changes the rotation of the last tile.
Name | Type | Description |
---|---|---|
rotate |
number |