1111 * @class PIXI.Tilemap
1212 * @extends {DisplayObjectContainer }
1313 * @param {PIXI.Texture } texture - The tilemap texture.
14- * @param {integer } mapwidth - The width of the map.
15- * @param {integer } mapheight - The height of the map.
16- * @param {integer } tilewidth 0- The width of a single tile.
17- * @param {integer } tileheight - The height of a single tile.
18- * @param {Array } layer - Tilemap layer data from the map, arranged in mapheight lists of mapwidth Phaser.Tile objects (2d array).
14+ * @param {integer } displayWidth - The width of the display area. Used as the clipping limit for the shader.
15+ * @param {integer } displayHeight - The height of the display area. Used as the clipping limit for the shader.
16+ * @param {integer } mapWidth - The width of the map.
17+ * @param {integer } mapHeight - The height of the map.
18+ * @param {integer } tileWidth - The width of a single tile.
19+ * @param {integer } tileHeight - The height of a single tile.
20+ * @param {Array } layer - Tilemap layer data from the map, arranged in mapHeight lists of mapWidth Phaser.Tile objects (2d array).
1921 */
20- PIXI . Tilemap = function ( texture , displaywidth , displayheight , mapwidth , mapheight , tilewidth , tileheight , layer ) {
22+ PIXI . Tilemap = function ( texture , displayWidth , displayHeight , mapWidth , mapHeight , tileWidth , tileHeight , layer ) {
2123
2224 PIXI . DisplayObjectContainer . call ( this ) ;
2325
2426 /**
25- * the clipping limits for this layer
27+ * The clipping limit of the display area.
28+ *
29+ * @property displayWidth
30+ * @type integer
31+ */
32+ this . displayWidth = displayWidth ;
33+
34+ /**
35+ * The clipping limit of the display area.
36+ *
37+ * @property displayHeight
38+ * @type integer
2639 */
27- this . displayWidth = displaywidth ;
28- this . displayHeight = displayheight ;
40+ this . displayHeight = displayHeight ;
2941
3042 /**
3143 * The texture of the Tilemap
@@ -35,41 +47,93 @@ PIXI.Tilemap = function (texture, displaywidth, displayheight, mapwidth, mapheig
3547 */
3648 this . texture = texture ;
3749
38- // faster access to the tile dimensions
39- this . tileWide = tilewidth ;
40- this . tileHigh = tileheight ;
41- this . mapWide = mapwidth ;
42- this . mapHigh = mapheight ;
50+ /**
51+ * The width of a single tile in pixels.
52+ *
53+ * @property tileWide
54+ * @type integer
55+ */
56+ this . tileWide = tileWidth ;
4357
44- // TODO: switch here to create DisplayObjectContainer at correct size for the render mode
58+ /**
59+ * The height of a single tile in pixels.
60+ *
61+ * @property tileHigh
62+ * @type integer
63+ */
64+ this . tileHigh = tileHeight ;
65+
66+ /**
67+ * The width of the map in tiles.
68+ *
69+ * @property mapWide
70+ * @type integer
71+ */
72+ this . mapWide = mapWidth ;
73+
74+ /**
75+ * The height of the map in tiles.
76+ *
77+ * @property mapHigh
78+ * @type integer
79+ */
80+ this . mapHigh = mapHeight ;
81+
82+ /**
83+ * The width of the map in pixels.
84+ *
85+ * @property width
86+ * @type integer
87+ */
4588 this . width = this . mapWide * this . tileWide ;
89+
90+ /**
91+ * The height of the map in pixels.
92+ *
93+ * @property height
94+ * @type integer
95+ */
4696 this . height = this . mapHigh * this . tileHigh ;
4797
98+ /**
99+ * Tilemap layer data from the map, arranged in mapHeight lists of mapWidth tiles.
100+ * Contains Phaser.Tile objects (2d array).
101+ *
102+ * @property layer
103+ * @type Array
104+ */
48105 this . layer = layer ;
49106
50- // store the list of batch drawing instructions (for use with WebGL rendering)
107+ /**
108+ * Store the list of batch drawing instructions.
109+ *
110+ * @property glBatch
111+ * @type Array
112+ */
51113 this . glBatch = null ;
52114
53115 /**
54- * Remember last tile drawn to avoid unnecessary set-up
116+ * Remember last tile drawn to avoid unnecessary set-up.
55117 *
56- * @type Integer
118+ * @property lastTile
119+ * @type integer
57120 */
58121 this . lastTile = - 1 ;
59122
60123 /**
61- * Whether the Tilemap is dirty or not
124+ * Whether the Tilemap is dirty or not.
62125 *
63126 * @property dirty
64- * @type Boolean
127+ * @type boolean
65128 */
66129 this . dirty = true ;
67130
68131 /**
69- * The blend mode to be applied to the tilemap. Set to PIXI.blendModes.NORMAL to remove any blend mode.
132+ * The blend mode to be applied to the tilemap.
133+ * Set to PIXI.blendModes.NORMAL to remove any blend mode.
70134 *
71135 * @property blendMode
72- * @type Number
136+ * @type integer
73137 * @default PIXI.blendModes.NORMAL;
74138 */
75139 this . blendMode = PIXI . blendModes . NORMAL ;
@@ -80,19 +144,22 @@ PIXI.Tilemap = function (texture, displaywidth, displayheight, mapwidth, mapheig
80144 * float left, bottom, right, top - screen coordinates
81145 * float u, v, wide, high - source texture coordinates
82146 *
83- * @type {Number }
147+ * @property batchDataElement
148+ * @type integer
84149 */
85150 this . batchDataElement = 16 ;
86151
87- // calculate total batch data size
88- var dataSize = mapwidth * mapheight * this . batchDataElement ;
89-
90- // create buffer data for the webgl rendering of this tile
91- this . buffer = new PIXI . Float32Array ( dataSize ) ;
152+ /**
153+ * Create the buffer data for the WebGL rendering of this tilemap.
154+ * Calculates the total batch data size.
155+ *
156+ * @property buffer
157+ * @type PIXI.Float32Array
158+ */
159+ this . buffer = new PIXI . Float32Array ( mapWidth * mapHeight * this . batchDataElement ) ;
92160
93161} ;
94162
95- // constructor, this class extends PIXI.DisplayObjectContainer
96163PIXI . Tilemap . prototype = Object . create ( PIXI . DisplayObjectContainer . prototype ) ;
97164PIXI . Tilemap . prototype . constructor = PIXI . Tilemap ;
98165
0 commit comments