2017-11-27 13:33:30 +00:00
|
|
|
/**
|
|
|
|
* Internally used method to convert from tile Y coordinates to world Y coordinates, factoring in
|
|
|
|
* layer position, scale and scroll.
|
|
|
|
*
|
2017-11-29 21:07:56 +00:00
|
|
|
* @param {integer} tileY - [description]
|
2017-11-27 13:33:30 +00:00
|
|
|
* @param {Camera} [camera=main camera] - [description]
|
|
|
|
* @param {LayerData} layer - [description]
|
|
|
|
* @returns {number}
|
|
|
|
*/
|
2017-11-26 13:55:44 +00:00
|
|
|
var TileToWorldY = function (tileY, camera, layer)
|
|
|
|
{
|
|
|
|
var tileHeight = layer.tileHeight;
|
|
|
|
var tilemapLayer = layer.tilemapLayer;
|
|
|
|
var layerWorldY = 0;
|
|
|
|
|
|
|
|
if (tilemapLayer)
|
|
|
|
{
|
|
|
|
if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; }
|
|
|
|
|
|
|
|
layerWorldY = tilemapLayer.y - (camera.scrollY * tilemapLayer.scrollFactorY);
|
|
|
|
|
|
|
|
tileHeight *= tilemapLayer.scaleY;
|
|
|
|
}
|
|
|
|
|
|
|
|
return layerWorldY + tileY * tileHeight;
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = TileToWorldY;
|