forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSetTileLocationCallback.js
More file actions
27 lines (23 loc) · 1.06 KB
/
Copy pathSetTileLocationCallback.js
File metadata and controls
27 lines (23 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
var GetTilesWithin = require('./GetTilesWithin');
/**
* Sets a collision callback for the given rectangular area (in tile coordindates) within the layer.
* If a callback is already set for the tile index it will be replaced. Set the callback to null to
* remove it.
*
* @param {integer} [tileX=0] - [description]
* @param {integer} [tileY=0] - [description]
* @param {integer} [width=max width based on tileX] - [description]
* @param {integer} [height=max height based on tileY] - [description]
* @param {function} callback - The callback that will be invoked when the tile is collided with.
* @param {object} callbackContext - The context under which the callback is called.
* @param {LayerData} layer - [description]
*/
var SetTileLocationCallback = function (tileX, tileY, width, height, callback, callbackContext, layer)
{
var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer);
for (var i = 0; i < tiles.length; i++)
{
tiles[i].setCollisionCallback(callback, callbackContext);
}
};
module.exports = SetTileLocationCallback;