LevelSelection

A collection of zero or more Level instances.

LevelSelection.where([tags])

Get the Levels in the collection that match the given tags.

Arguments

  • tags {Object}
    • Optional
    • Defaults to an empty object if nothing is passed, which would return all Levels.
    • An object of key value pairs to filter by
      • key: Name of tag
      • value: The value of the tag

Returns

  • LevelSelection {Array}
    • The new collection

LevelSelection.has([query]) => LevelSelection

Get a subset of the LevelSelection where the tags of each Level match the key-value query.

Arguments

  • query {Object}
    • Optional
    • Defaults to an empty object, which results in a no-op.
    • A key is the name of a tag.
    • A value is a boolean of whether or not the tag exists.

Returns

  • LevelSelection {Array}
    • The new collection

Example

map.levels().has({
    floor: true
})

LevelSelection.except([match]) => LevelSelection

Get a subset of the LevelSelection where the tags of each Level are not included in the given matches.

Arguments

  • match {Object}
    • Optional
    • Defaults to an empty object, which results in a no-op.
    • A key is the name of a tag.
    • A value is a value of the tag to match on.

Returns

  • LevelSelection {Array}
    • The new collection

Example

floors.except(floors.last().tags().only('floor')).hide()

LevelSelection.find(id) => LevelSelection

Get all Levels in the collection that match the given id/s.

Arguments

  • id {string|Array<string>}
    • A single id or an array of ids to look for.

Returns

  • LevelSelection {Array}
    • The new collection

LevelSelection.select(selector) => HitAreaSelection|UnitSelection

Get a collection of the given entity within the LevelSelection.

Arguments

  • selector {string}
    • The entities to retrieve. Valid values:
      • hitareas
      • units

Returns

  • HitAreaSelection|UnitSelection {Object}

LevelSelection.first() => LevelSelection

Get the first Level in the collection.

Returns

  • LevelSelection {Array}
    • The new collection

LevelSelection.last() => LevelSelection

Get the last Level in the collection.

Returns

  • LevelSelection {Array}
    • The new collection

LevelSelection.at(index) => LevelSelection

Arguments

  • index {integer}
    • The index of the desired Level.

Returns

  • LevelSelection {Array}
    • The new collection

LevelSelection.translate(x, y)

Move each Level in the collection by the given x and y. This method is chainable.

Arguments

  • x {number}
    • The value on the vertical axis.
  • y {number}
    • The value on the horizontal axis.

LevelSelection.scale(scale)

Set the scale each Level in the collection. This method is chainable.

Arguments

  • scale {float}
    • A positive float value
    • A value of 1 means a 1:1 ratio with the original scale of the level.
    • A value of 0.5 means half of the original scale.
    • A value of 2 means double of the original scale.

LevelSelection.each(iterator)

Iterator over each Level in the collection. This method is chainable.

LevelSelection.clone(id, tags) => LevelSelection

Get a new instance of the collection with identical attributes.

Arguments

  • id {string}
  • tags {Object}
    • Optional

Returns

  • LevelSelection {Array}
    • The new collection

LevelSelection.remove()

Remove all Levels in the collection from the map. This method is chainable.

LevelSelection.hide()

Hide the given LevelSelection. This method is chainable.

LevelSelection.show()

Display the given LevelSelection. This method is chainable.

LevelSelection.opacity(opacity)

Set the opacity of the LevelSelection. This method is chainable.

Arguments

  • opacity {decimal}
    • Number between 0 and 1.
    • The transparency-level, where 1 is not transparent at all, 0.5 is 50% see-through, and 0 is completely transparent.

LevelSelection.tags() => TagsCollection

Get the tags of the Level in JSON format.

Returns

  • tags {Object}
    • A JSON object

LevelSelection.data() => Data

Get the LevelSelection as a JSON payload.

Returns

  • Data {Object}
    • A JSON object

What’s Next