var TILE_BIAS = 16; var ProcessTileSeparationY = require('./ProcessTileSeparationY'); /** * Check the body against the given tile on the Y axis. * * @private * @method Phaser.Physics.Arcade#tileCheckY * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. * @param {Phaser.Tile} tile - The tile to check. * @param {Phaser.TilemapLayer} tilemapLayer - The tilemapLayer to collide against. * @return {number} The amount of separation that occurred. */ var TileCheckY = function (body, tile, tilemapLayer) { var oy = 0; var tileTop = tilemapLayer.tileToWorldX(tile.y); var tileHeight = tile.height * tilemapLayer.scaleY; var tileBottom = tileTop + tileHeight; if (body.deltaY() < 0 && !body.blocked.up && tile.collideDown && body.checkCollision.up) { // Body is moving UP if (tile.faceBottom && body.y < tileBottom) { oy = body.y - tileBottom; if (oy < -TILE_BIAS) { oy = 0; } } } else if (body.deltaY() > 0 && !body.blocked.down && tile.collideUp && body.checkCollision.down) { // Body is moving DOWN if (tile.faceTop && body.bottom > tileTop) { oy = body.bottom - tileTop; if (oy > TILE_BIAS) { oy = 0; } } } if (oy !== 0) { if (body.customSeparateY) { body.overlapY = oy; } else { ProcessTileSeparationY(body, oy); } } return oy; }; module.exports = TileCheckY;