2018-01-11 02:47:25 +00:00
|
|
|
var ProcessTileSeparationY = require('./ProcessTileSeparationY');
|
|
|
|
|
|
|
|
/**
|
2018-02-09 03:44:23 +00:00
|
|
|
* Check the body against the given tile on the Y axis.
|
|
|
|
*
|
|
|
|
* @function Phaser.Physics.Arcade.Tilemap.TileCheckY
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {Phaser.Physics.Arcade.Body} body - The Body object to separate.
|
|
|
|
* @param {Phaser.Tilemaps.Tile} tile - The tile to check.
|
|
|
|
* @param {number} tileTop - [description]
|
|
|
|
* @param {number} tileBottom - [description]
|
|
|
|
* @param {number} tileBias - [description]
|
|
|
|
*
|
|
|
|
* @return {number} The amount of separation that occurred.
|
|
|
|
*/
|
2018-01-17 01:03:13 +00:00
|
|
|
var TileCheckY = function (body, tile, tileTop, tileBottom, tileBias)
|
2018-01-11 02:47:25 +00:00
|
|
|
{
|
|
|
|
var oy = 0;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2018-01-11 14:32:07 +00:00
|
|
|
if (oy < -tileBias)
|
2018-01-11 02:47:25 +00:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
|
2018-01-11 14:32:07 +00:00
|
|
|
if (oy > tileBias)
|
2018-01-11 02:47:25 +00:00
|
|
|
{
|
|
|
|
oy = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (oy !== 0)
|
|
|
|
{
|
|
|
|
if (body.customSeparateY)
|
|
|
|
{
|
|
|
|
body.overlapY = oy;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ProcessTileSeparationY(body, oy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return oy;
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = TileCheckY;
|