added isoCullDistances parameter to DynamicTilemapLayer

This commit is contained in:
Svipal 2020-02-07 15:21:11 +01:00
parent d7a857697f
commit 1573e25214
6 changed files with 58 additions and 7 deletions

View file

@ -107097,6 +107097,7 @@ var Components = __webpack_require__(11);
var DynamicTilemapLayerRender = __webpack_require__(1337);
var GameObject = __webpack_require__(13);
var TilemapComponents = __webpack_require__(136);
var Vector2 = __webpack_require__(3);
/**
* @classdesc
@ -107234,6 +107235,18 @@ var DynamicTilemapLayer = new Class({
*/
this.skipCull = false;
/**
* In isometric mode, you can control the amount of distance (in tiles, from the cameras' borders) that the Cameras before culling.
* By default the camera will allow 1 full tile in all directions.
*
* However, there are some instances when you may wish to adjust this, and changing this variable allows you to do so.
*
* @name Phaser.Tilemaps.DynamicTilemapLayer#isoCullDistances
* @type {Phaser.Math.Vector2}
* @since 3.23.PR_svipal
*/
this.isoCullDistances = new Vector2(0, 0);
/**
* The total number of tiles drawn by the renderer in the last frame.
*
@ -175483,7 +175496,7 @@ var CreateFromTiles = function (indexes, replacements, spriteConfig, scene, came
if (indexes.indexOf(tile.index) !== -1)
{
var point = TileToWorldXY(tile.x,tile.y, camera, layer);
var point = TileToWorldXY(tile.x,tile.y, undefined, camera, layer);
spriteConfig.x = point.x;
spriteConfig.y = point.y;
var sprite = scene.make.sprite(spriteConfig);
@ -175589,8 +175602,12 @@ var CullTiles = function (layer, camera, outputArray, renderOrder)
{
inIsoBounds = function (x,y)
{
var cullDistances = tilemapLayer.isoCullDistances;
var pos = tilemapLayer.tileToWorldXY(x,y,undefined,camera);
return (pos.x > camera.worldView.x && pos.x < camera.worldView.right - layer.tileWidth) && (pos.y > camera.worldView.y && pos.y < camera.worldView.bottom - layer.tileHeight);
return pos.x > camera.worldView.x + tilemapLayer.scaleX * layer.tileWidth * (- cullDistances.x - 1 / 2)
&& pos.x < camera.worldView.right + tilemapLayer.scaleX * layer.tileWidth * (cullDistances.x - 1 / 2)
&& pos.y > camera.worldView.y + tilemapLayer.scaleY * layer.tileHeight * (- cullDistances.y - 1 / 2)
&& pos.y < camera.worldView.bottom + tilemapLayer.scaleY * layer.tileHeight * (cullDistances.y - 1 / 2);
};
}
}

File diff suppressed because one or more lines are too long

21
dist/phaser.js vendored
View file

@ -111763,6 +111763,7 @@ var Components = __webpack_require__(11);
var DynamicTilemapLayerRender = __webpack_require__(1337);
var GameObject = __webpack_require__(13);
var TilemapComponents = __webpack_require__(136);
var Vector2 = __webpack_require__(3);
/**
* @classdesc
@ -111900,6 +111901,18 @@ var DynamicTilemapLayer = new Class({
*/
this.skipCull = false;
/**
* In isometric mode, you can control the amount of distance (in tiles, from the cameras' borders) that the Cameras before culling.
* By default the camera will allow 1 full tile in all directions.
*
* However, there are some instances when you may wish to adjust this, and changing this variable allows you to do so.
*
* @name Phaser.Tilemaps.DynamicTilemapLayer#isoCullDistances
* @type {Phaser.Math.Vector2}
* @since 3.23.PR_svipal
*/
this.isoCullDistances = new Vector2(0, 0);
/**
* The total number of tiles drawn by the renderer in the last frame.
*
@ -183211,7 +183224,7 @@ var CreateFromTiles = function (indexes, replacements, spriteConfig, scene, came
if (indexes.indexOf(tile.index) !== -1)
{
var point = TileToWorldXY(tile.x,tile.y, camera, layer);
var point = TileToWorldXY(tile.x,tile.y, undefined, camera, layer);
spriteConfig.x = point.x;
spriteConfig.y = point.y;
var sprite = scene.make.sprite(spriteConfig);
@ -183317,8 +183330,12 @@ var CullTiles = function (layer, camera, outputArray, renderOrder)
{
inIsoBounds = function (x,y)
{
var cullDistances = tilemapLayer.isoCullDistances;
var pos = tilemapLayer.tileToWorldXY(x,y,undefined,camera);
return (pos.x > camera.worldView.x && pos.x < camera.worldView.right - layer.tileWidth) && (pos.y > camera.worldView.y && pos.y < camera.worldView.bottom - layer.tileHeight);
return pos.x > camera.worldView.x + tilemapLayer.scaleX * layer.tileWidth * (- cullDistances.x - 1 / 2)
&& pos.x < camera.worldView.right + tilemapLayer.scaleX * layer.tileWidth * (cullDistances.x - 1 / 2)
&& pos.y > camera.worldView.y + tilemapLayer.scaleY * layer.tileHeight * (- cullDistances.y - 1 / 2)
&& pos.y < camera.worldView.bottom + tilemapLayer.scaleY * layer.tileHeight * (cullDistances.y - 1 / 2);
};
}
}

2
dist/phaser.min.js vendored

File diff suppressed because one or more lines are too long

View file

@ -69,8 +69,12 @@ var CullTiles = function (layer, camera, outputArray, renderOrder)
{
inIsoBounds = function (x,y)
{
var cullDistances = tilemapLayer.isoCullDistances;
var pos = tilemapLayer.tileToWorldXY(x,y,undefined,camera);
return (pos.x > camera.worldView.x && pos.x < camera.worldView.right - layer.tileWidth) && (pos.y > camera.worldView.y && pos.y < camera.worldView.bottom - layer.tileHeight);
return pos.x > camera.worldView.x + tilemapLayer.scaleX * layer.tileWidth * (- cullDistances.x - 1 / 2)
&& pos.x < camera.worldView.right + tilemapLayer.scaleX * layer.tileWidth * (cullDistances.x - 1 / 2)
&& pos.y > camera.worldView.y + tilemapLayer.scaleY * layer.tileHeight * (- cullDistances.y - 1 / 2)
&& pos.y < camera.worldView.bottom + tilemapLayer.scaleY * layer.tileHeight * (cullDistances.y - 1 / 2);
};
}
}

View file

@ -9,6 +9,7 @@ var Components = require('../../gameobjects/components');
var DynamicTilemapLayerRender = require('./DynamicTilemapLayerRender');
var GameObject = require('../../gameobjects/GameObject');
var TilemapComponents = require('../components');
var Vector2 = require('../../math/Vector2');
/**
* @classdesc
@ -146,6 +147,18 @@ var DynamicTilemapLayer = new Class({
*/
this.skipCull = false;
/**
* In isometric mode, you can control the amount of distance (in tiles, from the cameras' borders) that the Cameras before culling.
* By default the camera will allow 1 full tile in all directions.
*
* However, there are some instances when you may wish to adjust this, and changing this variable allows you to do so.
*
* @name Phaser.Tilemaps.DynamicTilemapLayer#isoCullDistances
* @type {Phaser.Math.Vector2}
* @since 3.23.0
*/
this.isoCullDistances = new Vector2(1, 1);
/**
* The total number of tiles drawn by the renderer in the last frame.
*