@@ -2,12 +2,15 @@ var Class = require('../utils/Class');
22
33/**
44 * @classdesc
5- * An Image Collection is a special tileset containing mulitple images, with no slicing into each image.
5+ * An Image Collection is a special Tile Set containing multiple images, with no slicing into each image.
66 *
77 * Image Collections are normally created automatically when Tiled data is loaded.
88 *
9- * @class Phaser.ImageCollection
9+ * @class ImageCollection
10+ * @memberOf Phaser.Tilemaps
1011 * @constructor
12+ * @since 3.0.0
13+ *
1114 * @param {string } name - The name of the image collection in the map data.
1215 * @param {integer } firstgid - The first image index this image collection contains.
1316 * @param {integer } [width=32] - Width of widest image (in pixels).
@@ -28,99 +31,130 @@ var ImageCollection = new Class({
2831 if ( spacing === undefined ) { spacing = 0 ; }
2932
3033 /**
31- * The name of the Image Collection.
32- * @property {string } name
34+ * The name of the Image Collection.
35+ *
36+ * @name Phaser.Tilemaps.ImageCollection#name
37+ * @type {string }
38+ * @since 3.0.0
3339 */
3440 this . name = name ;
3541
3642 /**
37- * The Tiled firstgid value.
38- * This is the starting index of the first image index this Image Collection contains.
39- * @property {integer } firstgid
40- */
43+ * The Tiled firstgid value.
44+ * This is the starting index of the first image index this Image Collection contains.
45+ *
46+ * @name Phaser.Tilemaps.ImageCollection#firstgid
47+ * @type {integer }
48+ * @since 3.0.0
49+ */
4150 this . firstgid = firstgid | 0 ;
4251
4352 /**
44- * The width of the widest image (in pixels).
45- * @property {integer } imageWidth
46- * @readonly
47- */
53+ * The width of the widest image (in pixels).
54+ *
55+ * @name Phaser.Tilemaps.ImageCollection#imageWidth
56+ * @type {integer }
57+ * @readOnly
58+ * @since 3.0.0
59+ */
4860 this . imageWidth = width | 0 ;
4961
5062 /**
51- * The height of the tallest image (in pixels).
52- * @property {integer } imageHeight
53- * @readonly
54- */
63+ * The height of the tallest image (in pixels).
64+ *
65+ * @name Phaser.Tilemaps.ImageCollection#imageHeight
66+ * @type {integer }
67+ * @readOnly
68+ * @since 3.0.0
69+ */
5570 this . imageHeight = height | 0 ;
5671
5772 /**
58- * The margin around the images in the collection (in pixels).
59- * Use `setSpacing` to change.
60- * @property {integer } imageMarge
61- * @readonly
62- */
63- // Modified internally
73+ * The margin around the images in the collection (in pixels).
74+ * Use `setSpacing` to change.
75+ *
76+ * @name Phaser.Tilemaps.ImageCollection#imageMarge
77+ * @type {integer }
78+ * @readOnly
79+ * @since 3.0.0
80+ */
6481 this . imageMargin = margin | 0 ;
6582
6683 /**
67- * The spacing between each image in the collection (in pixels).
68- * Use `setSpacing` to change.
69- * @property {integer } imageSpacing
70- * @readonly
71- */
84+ * The spacing between each image in the collection (in pixels).
85+ * Use `setSpacing` to change.
86+ *
87+ * @name Phaser.Tilemaps.ImageCollection#imageSpacing
88+ * @type {integer }
89+ * @readOnly
90+ * @since 3.0.0
91+ */
7292 this . imageSpacing = spacing | 0 ;
7393
7494 /**
75- * Image Collection-specific properties that are typically defined in the Tiled editor.
76- * @property {object } properties
77- */
95+ * Image Collection-specific properties that are typically defined in the Tiled editor.
96+ *
97+ * @name Phaser.Tilemaps.ImageCollection#properties
98+ * @type {object }
99+ * @since 3.0.0
100+ */
78101 this . properties = properties || { } ;
79102
80103 /**
81- * The cached images that are a part of this collection.
82- * @property {array } images
83- * @readonly
84- */
85- // Modified internally
104+ * The cached images that are a part of this collection.
105+ *
106+ * @name Phaser.Tilemaps.ImageCollection#images
107+ * @type {array }
108+ * @readOnly
109+ * @since 3.0.0
110+ */
86111 this . images = [ ] ;
87112
88113 /**
89- * The total number of images in the image collection.
90- * @property {integer } total
91- * @readonly
92- */
93- // Modified internally
114+ * The total number of images in the image collection.
115+ *
116+ * @name Phaser.Tilemaps.ImageCollection#total
117+ * @type {integer }
118+ * @readOnly
119+ * @since 3.0.0
120+ */
94121 this . total = 0 ;
95122 } ,
96123
97124 /**
98- * Returns true if and only if this image collection contains the given image index.
99- *
100- * @method Phaser.ImageCollection#containsImageIndex
101- * @param {integer } imageIndex - The image index to search for.
102- * @return {boolean } True if this Image Collection contains the given index.
103- */
125+ * Returns true if and only if this image collection contains the given image index.
126+ *
127+ * @method Phaser.Tilemaps.ImageCollection#containsImageIndex
128+ * @since 3.0.0
129+ *
130+ * @param {integer } imageIndex - The image index to search for.
131+ *
132+ * @return {boolean } True if this Image Collection contains the given index.
133+ */
104134 containsImageIndex : function ( imageIndex )
105135 {
106- return (
107- imageIndex >= this . firstgid && imageIndex < ( this . firstgid + this . total )
108- ) ;
109-
136+ return ( imageIndex >= this . firstgid && imageIndex < ( this . firstgid + this . total ) ) ;
110137 } ,
111138
112139 /**
113- * Add an image to this Image Collection.
114- *
115- * @method Phaser.ImageCollection#addImage
116- * @param {integer } gid - The gid of the image in the Image Collection.
117- * @param {string } image - The the key of the image in the Image Collection and in the cache.
118- */
140+ * Add an image to this Image Collection.
141+ *
142+ * @method Phaser.Tilemaps.ImageCollection#addImage
143+ * @since 3.0.0
144+ *
145+ * @param {integer } gid - The gid of the image in the Image Collection.
146+ * @param {string } image - The the key of the image in the Image Collection and in the cache.
147+ *
148+ * @return {Phaser.Tilemaps.ImageCollection } This ImageCollection object.
149+ */
119150 addImage : function ( gid , image )
120151 {
121152 this . images . push ( { gid : gid , image : image } ) ;
122153 this . total ++ ;
154+
155+ return this ;
123156 }
157+
124158} ) ;
125159
126160module . exports = ImageCollection ;
0 commit comments