Class: ImageCollection

Phaser.Tilemaps. ImageCollection

An Image Collection is a special Tile Set containing multiple images, with no slicing into each image.

Image Collections are normally created automatically when Tiled data is loaded.


new ImageCollection(name, firstgid [, width] [, height] [, margin] [, spacing] [, properties])

Parameters:
Name Type Argument Default Description
name string

The name of the image collection in the map data.

firstgid integer

The first image index this image collection contains.

width integer <optional>
32

Width of widest image (in pixels).

height integer <optional>
32

Height of tallest image (in pixels).

margin integer <optional>
0

The margin around all images in the collection (in pixels).

spacing integer <optional>
0

The spacing between each image in the collection (in pixels).

properties object <optional>
{}

Custom Image Collection properties.

Since: 3.0.0
Source: src/tilemaps/ImageCollection.js (Line 9)

Members


firstgid :integer

The Tiled firstgid value.
This is the starting index of the first image index this Image Collection contains.

Type:
  • integer
Since: 3.0.0
Source: src/tilemaps/ImageCollection.js (Line 48)

<readonly> imageHeight :integer

The height of the tallest image (in pixels).

Type:
  • integer
Since: 3.0.0
Source: src/tilemaps/ImageCollection.js (Line 68)

<readonly> imageMarge :integer

The margin around the images in the collection (in pixels).
Use setSpacing to change.

Type:
  • integer
Since: 3.0.0
Source: src/tilemaps/ImageCollection.js (Line 78)

<readonly> images :array

The cached images that are a part of this collection.

Type:
  • array
Since: 3.0.0
Source: src/tilemaps/ImageCollection.js (Line 109)

<readonly> imageSpacing :integer

The spacing between each image in the collection (in pixels).
Use setSpacing to change.

Type:
  • integer
Since: 3.0.0
Source: src/tilemaps/ImageCollection.js (Line 89)

<readonly> imageWidth :integer

The width of the widest image (in pixels).

Type:
  • integer
Since: 3.0.0
Source: src/tilemaps/ImageCollection.js (Line 58)

name :string

The name of the Image Collection.

Type:
  • string
Since: 3.0.0
Source: src/tilemaps/ImageCollection.js (Line 39)

properties :object

Image Collection-specific properties that are typically defined in the Tiled editor.

Type:
  • object
Since: 3.0.0
Source: src/tilemaps/ImageCollection.js (Line 100)

<readonly> total :integer

The total number of images in the image collection.

Type:
  • integer
Since: 3.0.0
Source: src/tilemaps/ImageCollection.js (Line 119)

Methods


addImage(gid, image)

Add an image to this Image Collection.

Parameters:
Name Type Description
gid integer

The gid of the image in the Image Collection.

image string

The the key of the image in the Image Collection and in the cache.

Since: 3.0.0
Source: src/tilemaps/ImageCollection.js (Line 145)
Returns:

This ImageCollection object.

Type
Phaser.Tilemaps.ImageCollection

containsImageIndex(imageIndex)

Returns true if and only if this image collection contains the given image index.

Parameters:
Name Type Description
imageIndex integer

The image index to search for.

Since: 3.0.0
Source: src/tilemaps/ImageCollection.js (Line 130)
Returns:

True if this Image Collection contains the given index.

Type
boolean