@@ -2067,82 +2067,156 @@ var Tilemap = new Class({
20672067 } ,
20682068
20692069 /**
2070+ * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the
2071+ * layers position, scale and scroll. This will return a new Vector2 object or update the given
2072+ * `point` object.
2073+ *
20702074 * If no layer specified, the maps current layer is used.
20712075 *
2072- * @method Phaser.Tilemaps.Tilemap#removeTileAtWorldXY
2076+ * @method Phaser.Tilemaps.Tilemap#tileToWorldXY
20732077 * @since 3.0.0
20742078 *
2075- * @return {Vector2|null } Returns a point, or null if the layer given was invalid.
2079+ * @param {integer } tileX - [description]
2080+ * @param {integer } tileY - [description]
2081+ * @param {Phaser.Math.Vector2 } [point] - [description]
2082+ * @param {Phaser.Cameras.Scene2D.Camera } [camera=main camera] - [description]
2083+ * @param {Phaser.Tilemaps.LayerData } layer - [description]
2084+ *
2085+ * @return {Phaser.Math.Vector2|null } Returns a point, or null if the layer given was invalid.
20762086 */
20772087 tileToWorldXY : function ( tileX , tileY , point , camera , layer )
20782088 {
20792089 layer = this . getLayer ( layer ) ;
2090+
20802091 if ( layer === null ) { return null ; }
2092+
20812093 return TilemapComponents . TileToWorldXY ( tileX , tileY , point , camera , layer ) ;
20822094 } ,
20832095
20842096 /**
2097+ * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the
2098+ * specified layer. Each tile will receive a new index. New indexes are drawn from the given
2099+ * weightedIndexes array. An example weighted array:
2100+ *
2101+ * [
2102+ * { index: 6, weight: 4 }, // Probability of index 6 is 4 / 8
2103+ * { index: 7, weight: 2 }, // Probability of index 7 would be 2 / 8
2104+ * { index: 8, weight: 1.5 }, // Probability of index 8 would be 1.5 / 8
2105+ * { index: 26, weight: 0.5 } // Probability of index 27 would be 0.5 / 8
2106+ * ]
2107+ *
2108+ * The probability of any index being choose is (the index's weight) / (sum of all weights). This
2109+ * method only modifies tile indexes and does not change collision information.
2110+ *
20852111 * If no layer specified, the map's current layer is used. This
20862112 * cannot be applied to StaticTilemapLayers.
20872113 *
2088- * @method Phaser.Tilemaps.Tilemap#removeTileAtWorldXY
2114+ * @method Phaser.Tilemaps.Tilemap#weightedRandomize
20892115 * @since 3.0.0
20902116 *
2117+ * @param {integer } [tileX=0] - [description]
2118+ * @param {integer } [tileY=0] - [description]
2119+ * @param {integer } [width=max width based on tileX] - [description]
2120+ * @param {integer } [height=max height based on tileY] - [description]
2121+ * @param {object[] } [weightedIndexes] - An array of objects to randomly draw from during
2122+ * randomization. They should be in the form: { index: 0, weight: 4 } or
2123+ * { index: [0, 1], weight: 4 } if you wish to draw from multiple tile indexes.
2124+ * @param {Phaser.Tilemaps.LayerData } layer - [description]
2125+ *
20912126 * @returns {Phaser.Tilemaps.Tilemap|null } Return this Tilemap object, or null if the layer given was invalid.
20922127 */
20932128 weightedRandomize : function ( tileX , tileY , width , height , weightedIndexes , layer )
20942129 {
20952130 layer = this . getLayer ( layer ) ;
2131+
20962132 if ( this . _isStaticCall ( layer , 'weightedRandomize' ) ) { return this ; }
2133+
20972134 if ( layer !== null )
20982135 {
20992136 TilemapComponents . WeightedRandomize ( tileX , tileY , width , height , weightedIndexes , layer ) ;
21002137 }
2138+
21012139 return this ;
21022140 } ,
21032141
21042142 /**
2143+ * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the
2144+ * layers position, scale and scroll.
2145+ *
21052146 * If no layer specified, the maps current layer is used.
21062147 *
2107- * @method Phaser.Tilemaps.Tilemap#removeTileAtWorldXY
2148+ * @method Phaser.Tilemaps.Tilemap#worldToTileX
21082149 * @since 3.0.0
21092150 *
2151+ * @param {number } worldX - [description]
2152+ * @param {boolean } [snapToFloor=true] - Whether or not to round the tile coordinate down to the
2153+ * nearest integer.
2154+ * @param {Phaser.Cameras.Scene2D.Camera } [camera=main camera] - [description]
2155+ * @param {Phaser.Tilemaps.LayerData } layer - [description]
2156+ *
21102157 * @return {number|null } Returns a number, or null if the layer given was invalid.
21112158 */
21122159 worldToTileX : function ( worldX , snapToFloor , camera , layer )
21132160 {
21142161 layer = this . getLayer ( layer ) ;
2162+
21152163 if ( layer === null ) { return null ; }
2164+
21162165 return TilemapComponents . WorldToTileX ( worldX , snapToFloor , camera , layer ) ;
21172166 } ,
21182167
21192168 /**
2169+ * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the
2170+ * layers position, scale and scroll.
2171+ *
21202172 * If no layer specified, the maps current layer is used.
21212173 *
2122- * @method Phaser.Tilemaps.Tilemap#removeTileAtWorldXY
2174+ * @method Phaser.Tilemaps.Tilemap#worldToTileY
21232175 * @since 3.0.0
21242176 *
2177+ * @param {number } worldY - [description]
2178+ * @param {boolean } [snapToFloor=true] - Whether or not to round the tile coordinate down to the
2179+ * nearest integer.
2180+ * @param {Phaser.Cameras.Scene2D.Camera } [camera=main camera] - [description]
2181+ * @param {Phaser.Tilemaps.LayerData } layer - [description]
2182+ *
21252183 * @return {number|null } Returns a number, or null if the layer given was invalid.
21262184 */
21272185 worldToTileY : function ( worldY , snapToFloor , camera , layer )
21282186 {
21292187 layer = this . getLayer ( layer ) ;
2188+
21302189 if ( layer === null ) { return null ; }
2190+
21312191 return TilemapComponents . WorldToTileY ( worldY , snapToFloor , camera , layer ) ;
21322192 } ,
21332193
21342194 /**
2195+ * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the
2196+ * layers position, scale and scroll. This will return a new Vector2 object or update the given
2197+ * `point` object.
2198+ *
21352199 * If no layer specified, the maps current layer is used.
21362200 *
2137- * @method Phaser.Tilemaps.Tilemap#removeTileAtWorldXY
2201+ * @method Phaser.Tilemaps.Tilemap#worldToTileXY
21382202 * @since 3.0.0
21392203 *
2140- * @return {Vector2|null } Returns a point, or null if the layer given was invalid.
2204+ * @param {number } worldX - [description]
2205+ * @param {number } worldY - [description]
2206+ * @param {boolean } [snapToFloor=true] - Whether or not to round the tile coordinate down to the
2207+ * nearest integer.
2208+ * @param {Phaser.Math.Vector2 } [point] - [description]
2209+ * @param {Phaser.Cameras.Scene2D.Camera } [camera=main camera] - [description]
2210+ * @param {Phaser.Tilemaps.LayerData } layer - [description]
2211+ *
2212+ * @return {Phaser.Math.Vector2|null } Returns a point, or null if the layer given was invalid.
21412213 */
21422214 worldToTileXY : function ( worldX , worldY , snapToFloor , point , camera , layer )
21432215 {
21442216 layer = this . getLayer ( layer ) ;
2217+
21452218 if ( layer === null ) { return null ; }
2219+
21462220 return TilemapComponents . WorldToTileXY ( worldX , worldY , snapToFloor , point , camera , layer ) ;
21472221 } ,
21482222
0 commit comments