Navigation
These archived docs are for Phaser 2.4.8 Phaser 3 docs can be found on newdocs.phaser.io.
Phaser CE docs can be found on the Phaser CE Documentation site.

Constructor

Phaser. ImageCollection

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

An Image Collection is a special tileset containing mulitple images, with no slicing into each image.

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

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.

Source code: tilemap/ImageCollection.js (Line 22)

Public Properties

firstgid : integer

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

Source code: tilemap/ImageCollection.js (Line 40)

[readonly] imageHeight : integer

The height of the tallest image (in pixels).

Source code: tilemap/ImageCollection.js (Line 54)

[readonly] imageMargin

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

Properties:
Name Type Description
imageMarge integer
Source code: tilemap/ImageCollection.js (Line 63)

[readonly] images :array

The cached images that are a part of this collection.

Source code: tilemap/ImageCollection.js (Line 85)

[readonly] imageSpacing : integer

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

Source code: tilemap/ImageCollection.js (Line 71)

[readonly] imageWidth : integer

The width of the widest image (in pixels).

Source code: tilemap/ImageCollection.js (Line 47)

name : string

The name of the Image Collection.

Source code: tilemap/ImageCollection.js (Line 33)

properties : Object

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

Source code: tilemap/ImageCollection.js (Line 77)

[readonly] total : integer

The total number of images in the image collection.

Source code: tilemap/ImageCollection.js (Line 93)

Public 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.

Source code: tilemap/ImageCollection.js (Line 114)

containsImageIndex(imageIndex) → {boolean}

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.

Returns
boolean -

True if this Image Collection contains the given index.

Source code: tilemap/ImageCollection.js (Line 98)