mirror of
https://github.com/photonstorm/phaser
synced 2024-12-24 12:03:36 +00:00
19 lines
610 B
JavaScript
19 lines
610 B
JavaScript
|
var SnapFloor = require('../../../math/snap/SnapFloor');
|
||
|
|
||
|
var WorldToTileY = function (worldY, camera, layer)
|
||
|
{
|
||
|
var tilemapLayer = layer.tilemapLayer;
|
||
|
if (tilemapLayer)
|
||
|
{
|
||
|
if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; }
|
||
|
|
||
|
// Find the world position relative to the static or dynamic layer's top left origin,
|
||
|
// factoring in the camera's horizontal scroll
|
||
|
worldY = worldY + (camera.scrollY * tilemapLayer.scrollFactorY) - tilemapLayer.y;
|
||
|
}
|
||
|
|
||
|
return SnapFloor(worldY, layer.tileWidth) / layer.tileWidth;
|
||
|
};
|
||
|
|
||
|
module.exports = WorldToTileY;
|