Appearance
Summary
- Layers of map
- Get Shapes
- Get Shape by name
- tilemap
- viewport
- Listen mouse event
- Data of map
- Width of the map in pixels
- Height of the map in pixels
- The depth of the map in pixels (this is the height of a tile 😉))
- Get Layer by name
- Get index of tile
- Get origin position of tile
- Get tile by position
- Get tile by index
Layers of map ​
- Property:
layers
- Type:
object[]
- Optional:
true
- Read Only
- Usage:
Get Shapes ​
- Method:
map.getShapes()
- Return:
RpgShape[]
- Usage:
Return all shapes on the map
Get Shape by name ​
- Method:
map.getShape(name)
- Arguments:
- {
string
}name
. Name of shape (Optional:false
)
- {
- Return:
RpgShape[] | undefined
- Usage:
Returns a shape by its name. Returns undefined is nothing is found
tilemap ​
- Property:
tilemap
- Type:
PIXI.Container
- Optional:
true
- Usage:
Get the tilemap
viewport ​
- Property:
viewport
- Type:
PIXI.Viewport
- Optional:
false
- Usage:
The viewport of the map
It automatically follows the sprite representing the player but you can attach it to something else
Do not change the size of the viewport
Listen mouse event ​
- Since: 3.0.0-beta.4
- Method:
on(eventName,callback)
- Arguments:
- {
string
}eventName
. Name of the event (see PIXI documentation). Name often used in the codes
- {
- click
- mousedown
- mouseup
- mousemove
- pointerdown
- pointermove
- pointerup
- (etc...) (Optional:
false
)- {
(position: { x: number, y: number }, ev?: PIXI.InteractionEvent ) => any
}callback
. (Optional:false
)
- {
- Return:
void
- Example:
ts
sceneMap.on('pointerdown', (position) => {
console.log(position)
})
- Usage:
Listen to the events of the smile on the stage
Data of map ​
- Property:
data
- Type:
object
- Optional:
true
- Read Only
- Usage:
Width of the map in pixels ​
- Property:
widthPx
- Type:
number
- Optional:
true
- Read Only
- Usage:
Height of the map in pixels ​
- Property:
heightPx
- Type:
number
- Optional:
true
- Read Only
- Usage:
The depth of the map in pixels (this is the height of a tile 😉) ​
- Property:
map.zTileHeight
- Type:
number
- Optional:
false
- Read Only
- Usage:
Get Layer by name ​
- Method:
map.getLayerByName(name)
- Arguments:
- {
string
}name
. layer name (Optional:false
)
- {
- Return:
LayerInfo | undefined
- Example:
ts
const tiles = map.getLayerByName(0, 0)
- Usage:
Find a layer by name. Returns undefined
is the layer is not found
Get index of tile ​
- Method:
map.getTileIndex(x,y)
- Arguments:
- {
number
}x
. Position X (Optional:false
) - {
number
}x
. Position Y (Optional:false
)
- {
- Return:
number
- Usage:
Get the tile index on the tileset
Get origin position of tile ​
- Method:
map.getTileOriginPosition(x,y)
- Arguments:
- {
number
}x
. Position X (Optional:false
) - {
number
}x
. Position Y (Optional:false
)
- {
- Return:
{x: number, y: number }
- Example:
ts
// If the size of a tile is 32x32px
const position = map.getTileOriginPosition(35, 12)
console.log(position) // { x: 32, y: 0 }
- Usage:
Find the point of origin (top left) of a tile. Of course, its position depends on the size of the tile
Get tile by position ​
- Method:
map.getTileByPosition(x,y)
- Arguments:
- {
number
}x
. Position X (Optional:false
) - {
number
}x
. Position Y (Optional:false
)
- {
- Return:
TileInfo
- Example:
ts
const tiles = map.getTileByPosition(0, 0)
- Usage:
Recover tiles according to a position
Get tile by index ​
- Method:
map.getTileByIndex(tileIndex)
- Arguments:
- {
number
}tileIndex
. tile index (Optional:false
)
- {
- Return:
TileInfo
- Example:
ts
const index = map.getTileIndex(0, 0)
const tiles = map.getTileByIndex(index)
- Usage:
Retrieves tiles according to its index