# map id

  • Property: id
  • Type: string
  • Optional: true
  • Read Only
  • Usage:

# Layers of map

  • Property: layers
  • Type: object[]
  • Optional: true
  • Read Only
  • Usage:

# World X Position

  • Since: 3.0.0-beta.8
  • Property: worldX
  • Type: number
  • Optional: true
  • Read Only
  • Usage:

Retrieves the X position of the map in the world (0 if no world assigned)


# World Y Position

  • Since: 3.0.0-beta.8
  • Property: worldY
  • Type: number
  • Optional: true
  • Read Only
  • Usage:

Retrieves the Y position of the map in the world (0 if no world assigned)


# Create Shape

  • Since: 3.0.0-beta.3
  • Method: map.createShape(obj)
  • Arguments:
    • {object} obj. (Optional: false)
  • Return: RpgShape
  • Usage:

Create a shape dynamically on the map

Object:

  • (number) x: Position X
  • (number) y: Position Y
  • (number) width: Width
  • (number) height: Height
  • (object) properties (optionnal):
    • (number) z: Position Z
    • (hexadecimal) color: Color (shared with client)
    • (boolean) collision
    • You can your own properties

# Delete Shape

  • Method: map.removeShape(name)
  • Arguments:
    • {string} name. Name of shape (Optional: false)
  • Return: void
  • Usage:

Delete a shape


# 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


# Assign the map to a world

  • Since: 3.0.0-beta.8
  • Method: map.setInWorldMaps(name)
  • Arguments:
  • Usage:

Assign the map to a world


# Remove this map from the world

  • Since: 3.0.0-beta.8
  • Method: map.removeFromWorldMaps()
  • Return: boolean | undefined
  • Usage:

Remove this map from the world


# Get attached World

  • Since: 3.0.0-beta.8
  • Method: map.getInWorldMaps()
  • Usage:

Recover the world attached to this map (undefined if no world attached)


# event list

  • Property: events
  • Type: { [eventId: string]: RpgEvent }
  • Optional: true
  • Usage:

# Change Tile in map

  • Since: 3.0.0-beta.4
  • Method: map.setTile(x,y,layer,tileInfo)
  • Arguments:
    • {number} x. Position X (Optional: false)
    • {number} y. Position Y (Optional: false)
    • {string | ((layer: any) => boolean)} layer. Name of the layer where you want to put a tile. OYou can also put a function that will act as a filter. The first parameter is the layer and you return a boolean to indicate if you modify the tile of this layer or not (Optional: false)
    • {object} tileInfo. Object with the following properties:
  • {number} gid: The tile number in tileset (from 1)
  • {object} properties Property of the tile. You own object. To set a collision, set the collision:true property (Optional: false)
  • Return: void
  • Example:
map.setTile(15, 18, 'mylayer', { gid: 2 })
  • Usage:

Edit a tile on the map. All players on the map will see the modified tile


# Create Dynamic Event

  • Since: 3.0.0-beta.4
  • Method: map.createDynamicEvent(eventObj|eventObj[])
  • Arguments:
    • { { x: number, y: number, z?: number, event: eventClass } } eventsList. (Optional: false)
  • Return: { [eventId: string]: RpgEvent }
  • Usage:

Dynamically create an event in Shared mode

@EventData({
 name: 'EV-1'
})
class MyEvent extends RpgEvent {
 onAction() {
     console.log('ok')
 }
} 

map.createDynamicEvent({
     x: 100,
     y: 100,
     event: MyEvent
})

You can also put an array of objects to create several events at once


# Get Event

  • Since: 3.0.0-beta.7
  • Method: map.getEvent(eventId)
  • Arguments:
    • {string} eventId. Event Id (Optional: false)
  • Return: RpgEvent | undefined
  • Usage:

Get Event in current map


# Remove Event

  • Since: 3.0.0-beta.4
  • Method: map.removeEvent(eventId)
  • Arguments:
    • {string} eventId. Event Name (Optional: false)
  • Return: boolean
  • Usage:

Removes an event from the map. Returns false if the event is not found


# Create a temporary and moving hitbox

  • Since: 3.2.0
  • Method: map.createMovingHitbox(hitboxes,options)
  • Arguments:
    • {Array<{ width: number, height: number, x: number, y: number }>} hitboxes. Create several hitboxes that will give an effect of movement (Optional: false)
    • {object} options. (Optional: true)
    • {speed} options.speed. speed of movement (in frames) (Optional: true)
  • Return: Observable find the methods of position and movement of an event
  • Example:
// Two hitboxes that will be done very quickly
map.createMovingHitbox(
  [ 
     { x: 0, y: 0, width: 100, height: 100 },
     { x: 20, y: 0, width: 100, height: 100 } 
  ]
).subscribe({
     next(hitbox) {
         console.log(hitbox.otherPlayersCollision)
     },
     complete() {
         console.log('finish')
     }
})
  • Usage:

Allows to create a temporary hitbox on the map that can have a movement For example, you can use it to explode a bomb and find all the affected players, or during a sword strike, you can create a moving hitbox and find the affected players again


# 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:
 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:
 // 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:
 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:
 const index = map.getTileIndex(0, 0)
 const tiles = map.getTileByIndex(index)
  • Usage:

Retrieves tiles according to its index