mirror of
https://github.com/photonstorm/phaser
synced 2025-01-11 04:38:51 +00:00
28 lines
809 B
JavaScript
28 lines
809 B
JavaScript
/**
|
|
* Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the
|
|
* layer's position, scale and scroll.
|
|
*
|
|
* @param {integer} tileY - [description]
|
|
* @param {Camera} [camera=main camera] - [description]
|
|
* @param {LayerData} layer - [description]
|
|
* @returns {number}
|
|
*/
|
|
var TileToWorldY = function (tileY, camera, layer)
|
|
{
|
|
var tileHeight = layer.baseTileHeight;
|
|
var tilemapLayer = layer.tilemapLayer;
|
|
var layerWorldY = 0;
|
|
|
|
if (tilemapLayer)
|
|
{
|
|
if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; }
|
|
|
|
layerWorldY = (tilemapLayer.y + camera.scrollY * (1 - tilemapLayer.scrollFactorY));
|
|
|
|
tileHeight *= tilemapLayer.scaleY;
|
|
}
|
|
|
|
return layerWorldY + tileY * tileHeight;
|
|
};
|
|
|
|
module.exports = TileToWorldY;
|