mirror of
https://github.com/photonstorm/phaser
synced 2025-01-09 11:48:50 +00:00
added staggered support
This commit is contained in:
parent
9780592a90
commit
a7d4816564
12 changed files with 202 additions and 129 deletions
124
dist/phaser-arcade-physics.js
vendored
124
dist/phaser-arcade-physics.js
vendored
|
@ -11919,7 +11919,7 @@ var WorldToTileXY = function (worldX, worldY, snapToFloor, point, camera, layer)
|
||||||
point.x = WorldToTileX(worldX, snapToFloor, camera, layer, orientation);
|
point.x = WorldToTileX(worldX, snapToFloor, camera, layer, orientation);
|
||||||
point.y = WorldToTileY(worldY, snapToFloor, camera, layer, orientation);
|
point.y = WorldToTileY(worldY, snapToFloor, camera, layer, orientation);
|
||||||
}
|
}
|
||||||
else if (orientation === 'isometric')
|
else if (orientation === 'isometric' || orientation === 'staggered')
|
||||||
{
|
{
|
||||||
|
|
||||||
var tileWidth = layer.baseTileWidth;
|
var tileWidth = layer.baseTileWidth;
|
||||||
|
@ -11944,18 +11944,39 @@ var WorldToTileXY = function (worldX, worldY, snapToFloor, point, camera, layer)
|
||||||
|
|
||||||
tileWidth *= tilemapLayer.scaleX;
|
tileWidth *= tilemapLayer.scaleX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (orientation === 'isometric')
|
||||||
|
{
|
||||||
|
point.x = snapToFloor
|
||||||
|
? Math.floor((worldX / (tileWidth / 2) + worldY / (tileHeight / 2)) / 2)
|
||||||
|
: ((worldX / (tileWidth / 2) + worldY / (tileHeight / 2)) / 2);
|
||||||
|
|
||||||
point.x = snapToFloor
|
point.y = snapToFloor
|
||||||
? Math.floor((worldX / (tileWidth / 2) + worldY / (tileHeight / 2)) / 2)
|
? Math.floor((worldY / (tileHeight / 2) - worldX / (tileWidth / 2)) / 2)
|
||||||
: ((worldX / (tileWidth / 2) + worldY / (tileHeight / 2)) / 2);
|
: ((worldY / (tileHeight / 2) - worldX / (tileWidth / 2)) / 2);
|
||||||
|
}
|
||||||
point.y = snapToFloor
|
if (orientation === 'orthogonal')
|
||||||
? Math.floor((worldY / (tileHeight / 2) - worldX / (tileWidth / 2)) / 2)
|
{
|
||||||
: ((worldY / (tileHeight / 2) - worldX / (tileWidth / 2)) / 2);
|
point.x = snapToFloor
|
||||||
|
? Math.floor(worldX / tileWidth)
|
||||||
|
: worldX / tileWidth;
|
||||||
|
point.y = snapToFloor
|
||||||
|
? Math.floor(worldY / tileHeight)
|
||||||
|
: worldY / tileHeight;
|
||||||
|
}
|
||||||
|
else if (orientation === 'staggered')
|
||||||
|
{
|
||||||
|
// implement world to tile staggered
|
||||||
|
point.y = snapToFloor
|
||||||
|
? Math.floor((worldY / (tileHeight / 2)))
|
||||||
|
: (worldY / (tileHeight / 2));
|
||||||
|
point.x = snapToFloor
|
||||||
|
? Math.floor((worldX / tileWidth) - (point.y % 2))
|
||||||
|
: (worldX / tileWidth) - (point.y % 2);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return point;
|
return point;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -12004,7 +12025,6 @@ var Rectangle = __webpack_require__(439);
|
||||||
* support multiple tileset sizes within one map, but they are still placed at intervals of the
|
* support multiple tileset sizes within one map, but they are still placed at intervals of the
|
||||||
* base tile height.
|
* base tile height.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var Tile = new Class({
|
var Tile = new Class({
|
||||||
|
|
||||||
Mixins: [
|
Mixins: [
|
||||||
|
@ -12080,7 +12100,7 @@ var Tile = new Class({
|
||||||
* @type {integer}
|
* @type {integer}
|
||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
*/
|
*/
|
||||||
this.baseWidth = (baseWidth !== undefined && !baseWidth.isNaN()) ? baseWidth : width;
|
this.baseWidth = (baseWidth !== undefined) ? baseWidth : width;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The map's base height of a tile in pixels. Tiled maps support multiple tileset sizes
|
* The map's base height of a tile in pixels. Tiled maps support multiple tileset sizes
|
||||||
|
@ -12090,7 +12110,7 @@ var Tile = new Class({
|
||||||
* @type {integer}
|
* @type {integer}
|
||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
*/
|
*/
|
||||||
this.baseHeight = (baseHeight !== undefined && !baseWidth.isNaN()) ? baseHeight : height;
|
this.baseHeight = (baseHeight !== undefined) ? baseHeight : height;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The x coordinate of the top left of this tile in pixels. This is relative to the top left
|
* The x coordinate of the top left of this tile in pixels. This is relative to the top left
|
||||||
|
@ -12243,7 +12263,6 @@ var Tile = new Class({
|
||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
*/
|
*/
|
||||||
this.physics = {};
|
this.physics = {};
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -12684,7 +12703,6 @@ var Tile = new Class({
|
||||||
this.pixelX = this.x * this.baseWidth;
|
this.pixelX = this.x * this.baseWidth;
|
||||||
this.pixelY = this.y * this.baseHeight;
|
this.pixelY = this.y * this.baseHeight;
|
||||||
|
|
||||||
// console.log("orthopix "+this.pixelX+","+this.pixelY)
|
|
||||||
}
|
}
|
||||||
else if (this.layer.orientation === 'isometric')
|
else if (this.layer.orientation === 'isometric')
|
||||||
{
|
{
|
||||||
|
@ -12693,11 +12711,12 @@ var Tile = new Class({
|
||||||
this.pixelX = (this.x - this.y) * this.baseWidth * 0.5;
|
this.pixelX = (this.x - this.y) * this.baseWidth * 0.5;
|
||||||
this.pixelY = (this.x + this.y) * this.baseHeight * 0.5;
|
this.pixelY = (this.x + this.y) * this.baseHeight * 0.5;
|
||||||
|
|
||||||
// console.log("isopix from",this.x, this.y,"to", this.pixelX+","+this.pixelY)
|
|
||||||
}
|
}
|
||||||
else
|
else if (this.layer.orientation === 'staggered')
|
||||||
{
|
{
|
||||||
// console.warn("this map orientation is is.layer.orientation)
|
this.pixelX = this.x * this.baseWidth + this.y % 2 * (this.baseWidth / 2);
|
||||||
|
this.pixelY = this.y * (this.baseHeight / 2);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// this.pixelY = this.y * this.baseHeight - (this.height - this.baseHeight);
|
// this.pixelY = this.y * this.baseHeight - (this.height - this.baseHeight);
|
||||||
|
@ -19349,7 +19368,6 @@ var LayerData = new Class({
|
||||||
*/
|
*/
|
||||||
this.orientation = GetFastValue(config, 'orientation', 'orthogonal');
|
this.orientation = GetFastValue(config, 'orientation', 'orthogonal');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The width in pixels of the entire layer.
|
* The width in pixels of the entire layer.
|
||||||
*
|
*
|
||||||
|
@ -19448,8 +19466,6 @@ var LayerData = new Class({
|
||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
*/
|
*/
|
||||||
this.tilemapLayer = GetFastValue(config, 'tilemapLayer', null);
|
this.tilemapLayer = GetFastValue(config, 'tilemapLayer', null);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -26596,9 +26612,7 @@ var GetTileAt = function (tileX, tileY, nonNull, layer)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return tile;
|
return tile;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -47283,7 +47297,7 @@ var TileToWorldXY = function (tileX, tileY, point, camera, layer)
|
||||||
point.x = TileToWorldX(tileX, camera, layer, orientation);
|
point.x = TileToWorldX(tileX, camera, layer, orientation);
|
||||||
point.y = TileToWorldY(tileY, camera, layer, orientation);
|
point.y = TileToWorldY(tileY, camera, layer, orientation);
|
||||||
}
|
}
|
||||||
else if (orientation === 'isometric')
|
else if (orientation === 'isometric' || orientation === 'staggered')
|
||||||
{
|
{
|
||||||
|
|
||||||
var layerWorldX = 0;
|
var layerWorldX = 0;
|
||||||
|
@ -47299,9 +47313,18 @@ var TileToWorldXY = function (tileX, tileY, point, camera, layer)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (orientation === 'isometric')
|
||||||
point.x = layerWorldX + (tileX - tileY) * (tileWidth / 2);
|
{
|
||||||
point.y = layerWorldY + (tileX + tileY) * (tileHeight / 2);
|
point.x = layerWorldX + (tileX - tileY) * (tileWidth / 2);
|
||||||
|
point.y = layerWorldY + (tileX + tileY) * (tileHeight / 2);
|
||||||
|
}
|
||||||
|
else if (orientation === 'staggered')
|
||||||
|
{
|
||||||
|
// todo
|
||||||
|
point.x = layerWorldX + tileX * tileWidth + tileY % 2 * (tileWidth / 2);
|
||||||
|
point.y = layerWorldY + tileY * (tileHeight / 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47354,7 +47377,6 @@ var PutTileAt = function (tile, tileX, tileY, recalculateFaces, layer)
|
||||||
|
|
||||||
if (tile instanceof Tile)
|
if (tile instanceof Tile)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (layer.data[tileY][tileX] === null)
|
if (layer.data[tileY][tileX] === null)
|
||||||
{
|
{
|
||||||
layer.data[tileY][tileX] = new Tile(layer, tile.index, tileX, tileY, layer.tileWidth, layer.tileHeight);
|
layer.data[tileY][tileX] = new Tile(layer, tile.index, tileX, tileY, layer.tileWidth, layer.tileHeight);
|
||||||
|
@ -47366,7 +47388,6 @@ var PutTileAt = function (tile, tileX, tileY, recalculateFaces, layer)
|
||||||
var index = tile;
|
var index = tile;
|
||||||
if (layer.data[tileY][tileX] === null)
|
if (layer.data[tileY][tileX] === null)
|
||||||
{
|
{
|
||||||
|
|
||||||
layer.data[tileY][tileX] = new Tile(layer, index, tileX, tileY, layer.tileWidth, layer.tileHeight);
|
layer.data[tileY][tileX] = new Tile(layer, index, tileX, tileY, layer.tileWidth, layer.tileHeight);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -47385,7 +47406,7 @@ var PutTileAt = function (tile, tileX, tileY, recalculateFaces, layer)
|
||||||
{
|
{
|
||||||
CalculateFacesAt(tileX, tileY, layer);
|
CalculateFacesAt(tileX, tileY, layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
return newTile;
|
return newTile;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -101462,6 +101483,7 @@ module.exports = rbush;
|
||||||
var TileIntersectsBody = function (tileWorldRect, body)
|
var TileIntersectsBody = function (tileWorldRect, body)
|
||||||
{
|
{
|
||||||
// Currently, all bodies are treated as rectangles when colliding with a Tile.
|
// Currently, all bodies are treated as rectangles when colliding with a Tile.
|
||||||
|
|
||||||
return !(
|
return !(
|
||||||
body.right <= tileWorldRect.left ||
|
body.right <= tileWorldRect.left ||
|
||||||
body.bottom <= tileWorldRect.top ||
|
body.bottom <= tileWorldRect.top ||
|
||||||
|
@ -102633,7 +102655,6 @@ var TileToWorldX = function (tileX, camera, layer)
|
||||||
tileWidth *= tilemapLayer.scaleX;
|
tileWidth *= tilemapLayer.scaleX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (orientation === 'orthogonal')
|
if (orientation === 'orthogonal')
|
||||||
{
|
{
|
||||||
return layerWorldX + tileX * tileWidth;
|
return layerWorldX + tileX * tileWidth;
|
||||||
|
@ -103134,14 +103155,13 @@ var AssignTileProperties = __webpack_require__(489);
|
||||||
*/
|
*/
|
||||||
var ParseJSONTiled = function (name, json, insertNull)
|
var ParseJSONTiled = function (name, json, insertNull)
|
||||||
{
|
{
|
||||||
if (json.orientation === 'isometric')
|
if (json.orientation === 'isometric' || json.orientation === 'staggered')
|
||||||
{
|
{
|
||||||
console.warn('isometric map types are WIP in this version of Phaser');
|
console.warn('isometric map types are WIP in this version of Phaser');
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (json.orientation !== 'orthogonal')
|
else if (json.orientation !== 'orthogonal')
|
||||||
{
|
{
|
||||||
console.warn('Only orthogonal map types are supported in this version of Phaser');
|
console.warn('Only orthogonal and standard isometric map types are supported in this version of Phaser');
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105034,7 +105054,7 @@ var Tilemap = new Class({
|
||||||
height: height,
|
height: height,
|
||||||
orientation: this.orientation
|
orientation: this.orientation
|
||||||
});
|
});
|
||||||
|
|
||||||
var row;
|
var row;
|
||||||
|
|
||||||
for (var tileY = 0; tileY < height; tileY++)
|
for (var tileY = 0; tileY < height; tileY++)
|
||||||
|
@ -107243,9 +107263,9 @@ var DynamicTilemapLayer = new Class({
|
||||||
*
|
*
|
||||||
* @name Phaser.Tilemaps.DynamicTilemapLayer#isoCullDistances
|
* @name Phaser.Tilemaps.DynamicTilemapLayer#isoCullDistances
|
||||||
* @type {Phaser.Math.Vector2}
|
* @type {Phaser.Math.Vector2}
|
||||||
* @since 3.23.PR_svipal
|
* @since 3.23.0
|
||||||
*/
|
*/
|
||||||
this.isoCullDistances = new Vector2(0, 0);
|
this.isoCullDistances = new Vector2(1, 1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The total number of tiles drawn by the renderer in the last frame.
|
* The total number of tiles drawn by the renderer in the last frame.
|
||||||
|
@ -108448,7 +108468,7 @@ var Utils = __webpack_require__(9);
|
||||||
*
|
*
|
||||||
* Use a Static Tilemap Layer instead of a Dynamic Tilemap Layer when you don't need tile manipulation features.
|
* Use a Static Tilemap Layer instead of a Dynamic Tilemap Layer when you don't need tile manipulation features.
|
||||||
*
|
*
|
||||||
* @class StaticTilemapLayers
|
* @class StaticTilemapLayer
|
||||||
* @extends Phaser.GameObjects.GameObject
|
* @extends Phaser.GameObjects.GameObject
|
||||||
* @memberof Phaser.Tilemaps
|
* @memberof Phaser.Tilemaps
|
||||||
* @constructor
|
* @constructor
|
||||||
|
@ -109549,8 +109569,7 @@ var StaticTilemapLayer = new Class({
|
||||||
*/
|
*/
|
||||||
hasTileAtWorldXY: function (worldX, worldY, camera)
|
hasTileAtWorldXY: function (worldX, worldY, camera)
|
||||||
{
|
{
|
||||||
|
return TilemapComponents.HasTileAtWorldXY(worldX, worldY, camera, this.layer);
|
||||||
return TilemapComponents.HasTileAtWorldXY(worldX, worldY, camera);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -109746,14 +109765,13 @@ var StaticTilemapLayer = new Class({
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts from tile X and Y coordinates (tile units) to world X coordinates (pixels), factoring in the
|
* Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the
|
||||||
* layers position, scale and scroll.
|
* layers position, scale and scroll.
|
||||||
*
|
*
|
||||||
* @method Phaser.Tilemaps.StaticTilemapLayer#tileToWorldX
|
* @method Phaser.Tilemaps.StaticTilemapLayer#tileToWorldX
|
||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
*
|
*
|
||||||
* @param {integer} tileX - The X coordinate, in tile coordinates.
|
* @param {integer} tileX - The X coordinate, in tile coordinates.
|
||||||
* @param {integer} tileY - The Y coordinate, in tile coordinates.
|
|
||||||
* @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the world values from the tile index.
|
* @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the world values from the tile index.
|
||||||
*
|
*
|
||||||
* @return {number}
|
* @return {number}
|
||||||
|
@ -109764,14 +109782,13 @@ var StaticTilemapLayer = new Class({
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts from tile X and Y coordinates (tile units) to world Y coordinates (pixels), factoring in the
|
* Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the
|
||||||
* layers position, scale and scroll.
|
* layers position, scale and scroll.
|
||||||
*
|
*
|
||||||
* @method Phaser.Tilemaps.StaticTilemapLayer#tileToWorldY
|
* @method Phaser.Tilemaps.StaticTilemapLayer#tileToWorldY
|
||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
*
|
*
|
||||||
* @param {integer} tileY - The Y coordinate, in tile coordinates.
|
* @param {integer} tileY - The Y coordinate, in tile coordinates.
|
||||||
* @param {integer} tileY - The Y coordinate, in tile coordinates.
|
|
||||||
* @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the world values from the tile index.
|
* @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the world values from the tile index.
|
||||||
*
|
*
|
||||||
* @return {number}
|
* @return {number}
|
||||||
|
@ -175555,7 +175572,6 @@ var SnapCeil = __webpack_require__(326);
|
||||||
*/
|
*/
|
||||||
var CullTiles = function (layer, camera, outputArray, renderOrder)
|
var CullTiles = function (layer, camera, outputArray, renderOrder)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (outputArray === undefined) { outputArray = []; }
|
if (outputArray === undefined) { outputArray = []; }
|
||||||
if (renderOrder === undefined) { renderOrder = 0; }
|
if (renderOrder === undefined) { renderOrder = 0; }
|
||||||
|
|
||||||
|
@ -175579,11 +175595,11 @@ var CullTiles = function (layer, camera, outputArray, renderOrder)
|
||||||
var drawTop = 0;
|
var drawTop = 0;
|
||||||
var drawBottom = mapHeight;
|
var drawBottom = mapHeight;
|
||||||
|
|
||||||
// we define it earlier for it to make sense in scope
|
// we define the isometric culling function as a dummy early on for it to make sense in scope
|
||||||
var inIsoBounds = function () { return true; };
|
var inIsoBounds = function () { return true; };
|
||||||
if (!tilemapLayer.skipCull && tilemapLayer.scrollFactorX === 1 && tilemapLayer.scrollFactorY === 1)
|
if (!tilemapLayer.skipCull && tilemapLayer.scrollFactorX === 1 && tilemapLayer.scrollFactorY === 1)
|
||||||
{
|
{
|
||||||
if (layer.orientation === 'orthogonal')
|
if (layer.orientation === 'orthogonal' || layer.orientation === 'staggered')
|
||||||
{
|
{
|
||||||
// Camera world view bounds, snapped for scaled tile size
|
// Camera world view bounds, snapped for scaled tile size
|
||||||
// Cull Padding values are given in tiles, not pixels
|
// Cull Padding values are given in tiles, not pixels
|
||||||
|
@ -175596,6 +175612,7 @@ var CullTiles = function (layer, camera, outputArray, renderOrder)
|
||||||
drawLeft = Math.max(0, boundsLeft);
|
drawLeft = Math.max(0, boundsLeft);
|
||||||
drawRight = Math.min(mapWidth, boundsRight);
|
drawRight = Math.min(mapWidth, boundsRight);
|
||||||
drawTop = Math.max(0, boundsTop);
|
drawTop = Math.max(0, boundsTop);
|
||||||
|
|
||||||
drawBottom = Math.min(mapHeight, boundsBottom);
|
drawBottom = Math.min(mapHeight, boundsBottom);
|
||||||
}
|
}
|
||||||
else if (layer.orientation === 'isometric')
|
else if (layer.orientation === 'isometric')
|
||||||
|
@ -175604,6 +175621,8 @@ var CullTiles = function (layer, camera, outputArray, renderOrder)
|
||||||
{
|
{
|
||||||
var cullDistances = tilemapLayer.isoCullDistances;
|
var cullDistances = tilemapLayer.isoCullDistances;
|
||||||
var pos = tilemapLayer.tileToWorldXY(x,y,undefined,camera);
|
var pos = tilemapLayer.tileToWorldXY(x,y,undefined,camera);
|
||||||
|
|
||||||
|
// we always subtract 1/2 of the tile's height/width to make the culling distance start from the center of the tiles.
|
||||||
return pos.x > camera.worldView.x + tilemapLayer.scaleX * layer.tileWidth * (- cullDistances.x - 1 / 2)
|
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.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.y + tilemapLayer.scaleY * layer.tileHeight * (- cullDistances.y - 1 / 2)
|
||||||
|
@ -175616,7 +175635,7 @@ var CullTiles = function (layer, camera, outputArray, renderOrder)
|
||||||
var tile;
|
var tile;
|
||||||
|
|
||||||
|
|
||||||
if (layer.orientation === 'orthogonal')
|
if (layer.orientation === 'orthogonal' || layer.orientation === 'staggered')
|
||||||
{
|
{
|
||||||
|
|
||||||
if (renderOrder === 0)
|
if (renderOrder === 0)
|
||||||
|
@ -176174,7 +176193,7 @@ var TriangleToRectangle = function (triangle, rect)
|
||||||
* @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face.
|
* @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face.
|
||||||
* @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values.
|
* @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values.
|
||||||
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
|
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
|
||||||
*
|
*
|
||||||
* @return {Phaser.Tilemaps.Tile[]} Array of Tile objects.
|
* @return {Phaser.Tilemaps.Tile[]} Array of Tile objects.
|
||||||
*/
|
*/
|
||||||
var GetTilesWithinShape = function (shape, filteringOptions, camera, layer)
|
var GetTilesWithinShape = function (shape, filteringOptions, camera, layer)
|
||||||
|
@ -177415,7 +177434,7 @@ var DynamicTilemapLayerWebGLRenderer = function (renderer, src, interpolationPer
|
||||||
var frameWidth = 0;
|
var frameWidth = 0;
|
||||||
var frameHeight = 0;
|
var frameHeight = 0;
|
||||||
|
|
||||||
if (src.layer.orientation === 'isometric')
|
if (src.layer.orientation === 'isometric' || src.layer.orientation === 'staggered')
|
||||||
{
|
{
|
||||||
// we use the tileset width and height because in isometric maps the tileset's height is often different from the tilemap's.
|
// we use the tileset width and height because in isometric maps the tileset's height is often different from the tilemap's.
|
||||||
frameWidth = tileset.tileWidth;
|
frameWidth = tileset.tileWidth;
|
||||||
|
@ -177432,7 +177451,6 @@ var DynamicTilemapLayerWebGLRenderer = function (renderer, src, interpolationPer
|
||||||
|
|
||||||
var tw = frameWidth * 0.5;
|
var tw = frameWidth * 0.5;
|
||||||
var th = frameHeight * 0.5;
|
var th = frameHeight * 0.5;
|
||||||
|
|
||||||
|
|
||||||
var tint = getTint(tile.tint, alpha * tile.alpha);
|
var tint = getTint(tile.tint, alpha * tile.alpha);
|
||||||
|
|
||||||
|
@ -177559,7 +177577,7 @@ var DynamicTilemapLayerCanvasRenderer = function (renderer, src, interpolationPe
|
||||||
var width = tile.width;
|
var width = tile.width;
|
||||||
var height = tile.width;
|
var height = tile.width;
|
||||||
|
|
||||||
if (src.layer.orientation === 'isometric')
|
if (src.layer.orientation === 'isometric' || src.layer.orientation === 'staggered')
|
||||||
{
|
{
|
||||||
// we use the tileset width and height because in isometric maps the tileset's height is often different from the tilemap's.
|
// we use the tileset width and height because in isometric maps the tileset's height is often different from the tilemap's.
|
||||||
width = tileset.tileWidth;
|
width = tileset.tileWidth;
|
||||||
|
@ -177735,6 +177753,7 @@ module.exports = StaticTilemapLayerWebGLRenderer;
|
||||||
var StaticTilemapLayerCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix)
|
var StaticTilemapLayerCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix)
|
||||||
{
|
{
|
||||||
src.cull(camera);
|
src.cull(camera);
|
||||||
|
|
||||||
var renderTiles = src.culledTiles;
|
var renderTiles = src.culledTiles;
|
||||||
var tileCount = renderTiles.length;
|
var tileCount = renderTiles.length;
|
||||||
|
|
||||||
|
@ -177870,6 +177889,7 @@ GameObjectCreator.register('tilemap', function (config)
|
||||||
{
|
{
|
||||||
// Defaults are applied in ParseToTilemap
|
// Defaults are applied in ParseToTilemap
|
||||||
var c = (config !== undefined) ? config : {};
|
var c = (config !== undefined) ? config : {};
|
||||||
|
|
||||||
return ParseToTilemap(
|
return ParseToTilemap(
|
||||||
this.scene,
|
this.scene,
|
||||||
c.key,
|
c.key,
|
||||||
|
|
2
dist/phaser-arcade-physics.min.js
vendored
2
dist/phaser-arcade-physics.min.js
vendored
File diff suppressed because one or more lines are too long
124
dist/phaser.js
vendored
124
dist/phaser.js
vendored
|
@ -13843,7 +13843,7 @@ var WorldToTileXY = function (worldX, worldY, snapToFloor, point, camera, layer)
|
||||||
point.x = WorldToTileX(worldX, snapToFloor, camera, layer, orientation);
|
point.x = WorldToTileX(worldX, snapToFloor, camera, layer, orientation);
|
||||||
point.y = WorldToTileY(worldY, snapToFloor, camera, layer, orientation);
|
point.y = WorldToTileY(worldY, snapToFloor, camera, layer, orientation);
|
||||||
}
|
}
|
||||||
else if (orientation === 'isometric')
|
else if (orientation === 'isometric' || orientation === 'staggered')
|
||||||
{
|
{
|
||||||
|
|
||||||
var tileWidth = layer.baseTileWidth;
|
var tileWidth = layer.baseTileWidth;
|
||||||
|
@ -13868,18 +13868,39 @@ var WorldToTileXY = function (worldX, worldY, snapToFloor, point, camera, layer)
|
||||||
|
|
||||||
tileWidth *= tilemapLayer.scaleX;
|
tileWidth *= tilemapLayer.scaleX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (orientation === 'isometric')
|
||||||
|
{
|
||||||
|
point.x = snapToFloor
|
||||||
|
? Math.floor((worldX / (tileWidth / 2) + worldY / (tileHeight / 2)) / 2)
|
||||||
|
: ((worldX / (tileWidth / 2) + worldY / (tileHeight / 2)) / 2);
|
||||||
|
|
||||||
point.x = snapToFloor
|
point.y = snapToFloor
|
||||||
? Math.floor((worldX / (tileWidth / 2) + worldY / (tileHeight / 2)) / 2)
|
? Math.floor((worldY / (tileHeight / 2) - worldX / (tileWidth / 2)) / 2)
|
||||||
: ((worldX / (tileWidth / 2) + worldY / (tileHeight / 2)) / 2);
|
: ((worldY / (tileHeight / 2) - worldX / (tileWidth / 2)) / 2);
|
||||||
|
}
|
||||||
point.y = snapToFloor
|
if (orientation === 'orthogonal')
|
||||||
? Math.floor((worldY / (tileHeight / 2) - worldX / (tileWidth / 2)) / 2)
|
{
|
||||||
: ((worldY / (tileHeight / 2) - worldX / (tileWidth / 2)) / 2);
|
point.x = snapToFloor
|
||||||
|
? Math.floor(worldX / tileWidth)
|
||||||
|
: worldX / tileWidth;
|
||||||
|
point.y = snapToFloor
|
||||||
|
? Math.floor(worldY / tileHeight)
|
||||||
|
: worldY / tileHeight;
|
||||||
|
}
|
||||||
|
else if (orientation === 'staggered')
|
||||||
|
{
|
||||||
|
// implement world to tile staggered
|
||||||
|
point.y = snapToFloor
|
||||||
|
? Math.floor((worldY / (tileHeight / 2)))
|
||||||
|
: (worldY / (tileHeight / 2));
|
||||||
|
point.x = snapToFloor
|
||||||
|
? Math.floor((worldX / tileWidth) - (point.y % 2))
|
||||||
|
: (worldX / tileWidth) - (point.y % 2);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return point;
|
return point;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -13928,7 +13949,6 @@ var Rectangle = __webpack_require__(439);
|
||||||
* support multiple tileset sizes within one map, but they are still placed at intervals of the
|
* support multiple tileset sizes within one map, but they are still placed at intervals of the
|
||||||
* base tile height.
|
* base tile height.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var Tile = new Class({
|
var Tile = new Class({
|
||||||
|
|
||||||
Mixins: [
|
Mixins: [
|
||||||
|
@ -14004,7 +14024,7 @@ var Tile = new Class({
|
||||||
* @type {integer}
|
* @type {integer}
|
||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
*/
|
*/
|
||||||
this.baseWidth = (baseWidth !== undefined && !baseWidth.isNaN()) ? baseWidth : width;
|
this.baseWidth = (baseWidth !== undefined) ? baseWidth : width;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The map's base height of a tile in pixels. Tiled maps support multiple tileset sizes
|
* The map's base height of a tile in pixels. Tiled maps support multiple tileset sizes
|
||||||
|
@ -14014,7 +14034,7 @@ var Tile = new Class({
|
||||||
* @type {integer}
|
* @type {integer}
|
||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
*/
|
*/
|
||||||
this.baseHeight = (baseHeight !== undefined && !baseWidth.isNaN()) ? baseHeight : height;
|
this.baseHeight = (baseHeight !== undefined) ? baseHeight : height;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The x coordinate of the top left of this tile in pixels. This is relative to the top left
|
* The x coordinate of the top left of this tile in pixels. This is relative to the top left
|
||||||
|
@ -14167,7 +14187,6 @@ var Tile = new Class({
|
||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
*/
|
*/
|
||||||
this.physics = {};
|
this.physics = {};
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14608,7 +14627,6 @@ var Tile = new Class({
|
||||||
this.pixelX = this.x * this.baseWidth;
|
this.pixelX = this.x * this.baseWidth;
|
||||||
this.pixelY = this.y * this.baseHeight;
|
this.pixelY = this.y * this.baseHeight;
|
||||||
|
|
||||||
// console.log("orthopix "+this.pixelX+","+this.pixelY)
|
|
||||||
}
|
}
|
||||||
else if (this.layer.orientation === 'isometric')
|
else if (this.layer.orientation === 'isometric')
|
||||||
{
|
{
|
||||||
|
@ -14617,11 +14635,12 @@ var Tile = new Class({
|
||||||
this.pixelX = (this.x - this.y) * this.baseWidth * 0.5;
|
this.pixelX = (this.x - this.y) * this.baseWidth * 0.5;
|
||||||
this.pixelY = (this.x + this.y) * this.baseHeight * 0.5;
|
this.pixelY = (this.x + this.y) * this.baseHeight * 0.5;
|
||||||
|
|
||||||
// console.log("isopix from",this.x, this.y,"to", this.pixelX+","+this.pixelY)
|
|
||||||
}
|
}
|
||||||
else
|
else if (this.layer.orientation === 'staggered')
|
||||||
{
|
{
|
||||||
// console.warn("this map orientation is is.layer.orientation)
|
this.pixelX = this.x * this.baseWidth + this.y % 2 * (this.baseWidth / 2);
|
||||||
|
this.pixelY = this.y * (this.baseHeight / 2);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// this.pixelY = this.y * this.baseHeight - (this.height - this.baseHeight);
|
// this.pixelY = this.y * this.baseHeight - (this.height - this.baseHeight);
|
||||||
|
@ -22101,7 +22120,6 @@ var LayerData = new Class({
|
||||||
*/
|
*/
|
||||||
this.orientation = GetFastValue(config, 'orientation', 'orthogonal');
|
this.orientation = GetFastValue(config, 'orientation', 'orthogonal');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The width in pixels of the entire layer.
|
* The width in pixels of the entire layer.
|
||||||
*
|
*
|
||||||
|
@ -22200,8 +22218,6 @@ var LayerData = new Class({
|
||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
*/
|
*/
|
||||||
this.tilemapLayer = GetFastValue(config, 'tilemapLayer', null);
|
this.tilemapLayer = GetFastValue(config, 'tilemapLayer', null);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -29705,9 +29721,7 @@ var GetTileAt = function (tileX, tileY, nonNull, layer)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return tile;
|
return tile;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -51573,7 +51587,7 @@ var TileToWorldXY = function (tileX, tileY, point, camera, layer)
|
||||||
point.x = TileToWorldX(tileX, camera, layer, orientation);
|
point.x = TileToWorldX(tileX, camera, layer, orientation);
|
||||||
point.y = TileToWorldY(tileY, camera, layer, orientation);
|
point.y = TileToWorldY(tileY, camera, layer, orientation);
|
||||||
}
|
}
|
||||||
else if (orientation === 'isometric')
|
else if (orientation === 'isometric' || orientation === 'staggered')
|
||||||
{
|
{
|
||||||
|
|
||||||
var layerWorldX = 0;
|
var layerWorldX = 0;
|
||||||
|
@ -51589,9 +51603,18 @@ var TileToWorldXY = function (tileX, tileY, point, camera, layer)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (orientation === 'isometric')
|
||||||
point.x = layerWorldX + (tileX - tileY) * (tileWidth / 2);
|
{
|
||||||
point.y = layerWorldY + (tileX + tileY) * (tileHeight / 2);
|
point.x = layerWorldX + (tileX - tileY) * (tileWidth / 2);
|
||||||
|
point.y = layerWorldY + (tileX + tileY) * (tileHeight / 2);
|
||||||
|
}
|
||||||
|
else if (orientation === 'staggered')
|
||||||
|
{
|
||||||
|
// todo
|
||||||
|
point.x = layerWorldX + tileX * tileWidth + tileY % 2 * (tileWidth / 2);
|
||||||
|
point.y = layerWorldY + tileY * (tileHeight / 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51644,7 +51667,6 @@ var PutTileAt = function (tile, tileX, tileY, recalculateFaces, layer)
|
||||||
|
|
||||||
if (tile instanceof Tile)
|
if (tile instanceof Tile)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (layer.data[tileY][tileX] === null)
|
if (layer.data[tileY][tileX] === null)
|
||||||
{
|
{
|
||||||
layer.data[tileY][tileX] = new Tile(layer, tile.index, tileX, tileY, layer.tileWidth, layer.tileHeight);
|
layer.data[tileY][tileX] = new Tile(layer, tile.index, tileX, tileY, layer.tileWidth, layer.tileHeight);
|
||||||
|
@ -51656,7 +51678,6 @@ var PutTileAt = function (tile, tileX, tileY, recalculateFaces, layer)
|
||||||
var index = tile;
|
var index = tile;
|
||||||
if (layer.data[tileY][tileX] === null)
|
if (layer.data[tileY][tileX] === null)
|
||||||
{
|
{
|
||||||
|
|
||||||
layer.data[tileY][tileX] = new Tile(layer, index, tileX, tileY, layer.tileWidth, layer.tileHeight);
|
layer.data[tileY][tileX] = new Tile(layer, index, tileX, tileY, layer.tileWidth, layer.tileHeight);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -51675,7 +51696,7 @@ var PutTileAt = function (tile, tileX, tileY, recalculateFaces, layer)
|
||||||
{
|
{
|
||||||
CalculateFacesAt(tileX, tileY, layer);
|
CalculateFacesAt(tileX, tileY, layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
return newTile;
|
return newTile;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -106003,6 +106024,7 @@ module.exports = rbush;
|
||||||
var TileIntersectsBody = function (tileWorldRect, body)
|
var TileIntersectsBody = function (tileWorldRect, body)
|
||||||
{
|
{
|
||||||
// Currently, all bodies are treated as rectangles when colliding with a Tile.
|
// Currently, all bodies are treated as rectangles when colliding with a Tile.
|
||||||
|
|
||||||
return !(
|
return !(
|
||||||
body.right <= tileWorldRect.left ||
|
body.right <= tileWorldRect.left ||
|
||||||
body.bottom <= tileWorldRect.top ||
|
body.bottom <= tileWorldRect.top ||
|
||||||
|
@ -107299,7 +107321,6 @@ var TileToWorldX = function (tileX, camera, layer)
|
||||||
tileWidth *= tilemapLayer.scaleX;
|
tileWidth *= tilemapLayer.scaleX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (orientation === 'orthogonal')
|
if (orientation === 'orthogonal')
|
||||||
{
|
{
|
||||||
return layerWorldX + tileX * tileWidth;
|
return layerWorldX + tileX * tileWidth;
|
||||||
|
@ -107800,14 +107821,13 @@ var AssignTileProperties = __webpack_require__(489);
|
||||||
*/
|
*/
|
||||||
var ParseJSONTiled = function (name, json, insertNull)
|
var ParseJSONTiled = function (name, json, insertNull)
|
||||||
{
|
{
|
||||||
if (json.orientation === 'isometric')
|
if (json.orientation === 'isometric' || json.orientation === 'staggered')
|
||||||
{
|
{
|
||||||
console.warn('isometric map types are WIP in this version of Phaser');
|
console.warn('isometric map types are WIP in this version of Phaser');
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (json.orientation !== 'orthogonal')
|
else if (json.orientation !== 'orthogonal')
|
||||||
{
|
{
|
||||||
console.warn('Only orthogonal map types are supported in this version of Phaser');
|
console.warn('Only orthogonal and standard isometric map types are supported in this version of Phaser');
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109700,7 +109720,7 @@ var Tilemap = new Class({
|
||||||
height: height,
|
height: height,
|
||||||
orientation: this.orientation
|
orientation: this.orientation
|
||||||
});
|
});
|
||||||
|
|
||||||
var row;
|
var row;
|
||||||
|
|
||||||
for (var tileY = 0; tileY < height; tileY++)
|
for (var tileY = 0; tileY < height; tileY++)
|
||||||
|
@ -111909,9 +111929,9 @@ var DynamicTilemapLayer = new Class({
|
||||||
*
|
*
|
||||||
* @name Phaser.Tilemaps.DynamicTilemapLayer#isoCullDistances
|
* @name Phaser.Tilemaps.DynamicTilemapLayer#isoCullDistances
|
||||||
* @type {Phaser.Math.Vector2}
|
* @type {Phaser.Math.Vector2}
|
||||||
* @since 3.23.PR_svipal
|
* @since 3.23.0
|
||||||
*/
|
*/
|
||||||
this.isoCullDistances = new Vector2(0, 0);
|
this.isoCullDistances = new Vector2(1, 1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The total number of tiles drawn by the renderer in the last frame.
|
* The total number of tiles drawn by the renderer in the last frame.
|
||||||
|
@ -113114,7 +113134,7 @@ var Utils = __webpack_require__(9);
|
||||||
*
|
*
|
||||||
* Use a Static Tilemap Layer instead of a Dynamic Tilemap Layer when you don't need tile manipulation features.
|
* Use a Static Tilemap Layer instead of a Dynamic Tilemap Layer when you don't need tile manipulation features.
|
||||||
*
|
*
|
||||||
* @class StaticTilemapLayers
|
* @class StaticTilemapLayer
|
||||||
* @extends Phaser.GameObjects.GameObject
|
* @extends Phaser.GameObjects.GameObject
|
||||||
* @memberof Phaser.Tilemaps
|
* @memberof Phaser.Tilemaps
|
||||||
* @constructor
|
* @constructor
|
||||||
|
@ -114215,8 +114235,7 @@ var StaticTilemapLayer = new Class({
|
||||||
*/
|
*/
|
||||||
hasTileAtWorldXY: function (worldX, worldY, camera)
|
hasTileAtWorldXY: function (worldX, worldY, camera)
|
||||||
{
|
{
|
||||||
|
return TilemapComponents.HasTileAtWorldXY(worldX, worldY, camera, this.layer);
|
||||||
return TilemapComponents.HasTileAtWorldXY(worldX, worldY, camera);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -114412,14 +114431,13 @@ var StaticTilemapLayer = new Class({
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts from tile X and Y coordinates (tile units) to world X coordinates (pixels), factoring in the
|
* Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the
|
||||||
* layers position, scale and scroll.
|
* layers position, scale and scroll.
|
||||||
*
|
*
|
||||||
* @method Phaser.Tilemaps.StaticTilemapLayer#tileToWorldX
|
* @method Phaser.Tilemaps.StaticTilemapLayer#tileToWorldX
|
||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
*
|
*
|
||||||
* @param {integer} tileX - The X coordinate, in tile coordinates.
|
* @param {integer} tileX - The X coordinate, in tile coordinates.
|
||||||
* @param {integer} tileY - The Y coordinate, in tile coordinates.
|
|
||||||
* @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the world values from the tile index.
|
* @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the world values from the tile index.
|
||||||
*
|
*
|
||||||
* @return {number}
|
* @return {number}
|
||||||
|
@ -114430,14 +114448,13 @@ var StaticTilemapLayer = new Class({
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts from tile X and Y coordinates (tile units) to world Y coordinates (pixels), factoring in the
|
* Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the
|
||||||
* layers position, scale and scroll.
|
* layers position, scale and scroll.
|
||||||
*
|
*
|
||||||
* @method Phaser.Tilemaps.StaticTilemapLayer#tileToWorldY
|
* @method Phaser.Tilemaps.StaticTilemapLayer#tileToWorldY
|
||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
*
|
*
|
||||||
* @param {integer} tileY - The Y coordinate, in tile coordinates.
|
* @param {integer} tileY - The Y coordinate, in tile coordinates.
|
||||||
* @param {integer} tileY - The Y coordinate, in tile coordinates.
|
|
||||||
* @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the world values from the tile index.
|
* @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the world values from the tile index.
|
||||||
*
|
*
|
||||||
* @return {number}
|
* @return {number}
|
||||||
|
@ -183283,7 +183300,6 @@ var SnapCeil = __webpack_require__(326);
|
||||||
*/
|
*/
|
||||||
var CullTiles = function (layer, camera, outputArray, renderOrder)
|
var CullTiles = function (layer, camera, outputArray, renderOrder)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (outputArray === undefined) { outputArray = []; }
|
if (outputArray === undefined) { outputArray = []; }
|
||||||
if (renderOrder === undefined) { renderOrder = 0; }
|
if (renderOrder === undefined) { renderOrder = 0; }
|
||||||
|
|
||||||
|
@ -183307,11 +183323,11 @@ var CullTiles = function (layer, camera, outputArray, renderOrder)
|
||||||
var drawTop = 0;
|
var drawTop = 0;
|
||||||
var drawBottom = mapHeight;
|
var drawBottom = mapHeight;
|
||||||
|
|
||||||
// we define it earlier for it to make sense in scope
|
// we define the isometric culling function as a dummy early on for it to make sense in scope
|
||||||
var inIsoBounds = function () { return true; };
|
var inIsoBounds = function () { return true; };
|
||||||
if (!tilemapLayer.skipCull && tilemapLayer.scrollFactorX === 1 && tilemapLayer.scrollFactorY === 1)
|
if (!tilemapLayer.skipCull && tilemapLayer.scrollFactorX === 1 && tilemapLayer.scrollFactorY === 1)
|
||||||
{
|
{
|
||||||
if (layer.orientation === 'orthogonal')
|
if (layer.orientation === 'orthogonal' || layer.orientation === 'staggered')
|
||||||
{
|
{
|
||||||
// Camera world view bounds, snapped for scaled tile size
|
// Camera world view bounds, snapped for scaled tile size
|
||||||
// Cull Padding values are given in tiles, not pixels
|
// Cull Padding values are given in tiles, not pixels
|
||||||
|
@ -183324,6 +183340,7 @@ var CullTiles = function (layer, camera, outputArray, renderOrder)
|
||||||
drawLeft = Math.max(0, boundsLeft);
|
drawLeft = Math.max(0, boundsLeft);
|
||||||
drawRight = Math.min(mapWidth, boundsRight);
|
drawRight = Math.min(mapWidth, boundsRight);
|
||||||
drawTop = Math.max(0, boundsTop);
|
drawTop = Math.max(0, boundsTop);
|
||||||
|
|
||||||
drawBottom = Math.min(mapHeight, boundsBottom);
|
drawBottom = Math.min(mapHeight, boundsBottom);
|
||||||
}
|
}
|
||||||
else if (layer.orientation === 'isometric')
|
else if (layer.orientation === 'isometric')
|
||||||
|
@ -183332,6 +183349,8 @@ var CullTiles = function (layer, camera, outputArray, renderOrder)
|
||||||
{
|
{
|
||||||
var cullDistances = tilemapLayer.isoCullDistances;
|
var cullDistances = tilemapLayer.isoCullDistances;
|
||||||
var pos = tilemapLayer.tileToWorldXY(x,y,undefined,camera);
|
var pos = tilemapLayer.tileToWorldXY(x,y,undefined,camera);
|
||||||
|
|
||||||
|
// we always subtract 1/2 of the tile's height/width to make the culling distance start from the center of the tiles.
|
||||||
return pos.x > camera.worldView.x + tilemapLayer.scaleX * layer.tileWidth * (- cullDistances.x - 1 / 2)
|
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.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.y + tilemapLayer.scaleY * layer.tileHeight * (- cullDistances.y - 1 / 2)
|
||||||
|
@ -183344,7 +183363,7 @@ var CullTiles = function (layer, camera, outputArray, renderOrder)
|
||||||
var tile;
|
var tile;
|
||||||
|
|
||||||
|
|
||||||
if (layer.orientation === 'orthogonal')
|
if (layer.orientation === 'orthogonal' || layer.orientation === 'staggered')
|
||||||
{
|
{
|
||||||
|
|
||||||
if (renderOrder === 0)
|
if (renderOrder === 0)
|
||||||
|
@ -183902,7 +183921,7 @@ var TriangleToRectangle = function (triangle, rect)
|
||||||
* @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face.
|
* @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face.
|
||||||
* @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values.
|
* @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values.
|
||||||
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
|
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
|
||||||
*
|
*
|
||||||
* @return {Phaser.Tilemaps.Tile[]} Array of Tile objects.
|
* @return {Phaser.Tilemaps.Tile[]} Array of Tile objects.
|
||||||
*/
|
*/
|
||||||
var GetTilesWithinShape = function (shape, filteringOptions, camera, layer)
|
var GetTilesWithinShape = function (shape, filteringOptions, camera, layer)
|
||||||
|
@ -185143,7 +185162,7 @@ var DynamicTilemapLayerWebGLRenderer = function (renderer, src, interpolationPer
|
||||||
var frameWidth = 0;
|
var frameWidth = 0;
|
||||||
var frameHeight = 0;
|
var frameHeight = 0;
|
||||||
|
|
||||||
if (src.layer.orientation === 'isometric')
|
if (src.layer.orientation === 'isometric' || src.layer.orientation === 'staggered')
|
||||||
{
|
{
|
||||||
// we use the tileset width and height because in isometric maps the tileset's height is often different from the tilemap's.
|
// we use the tileset width and height because in isometric maps the tileset's height is often different from the tilemap's.
|
||||||
frameWidth = tileset.tileWidth;
|
frameWidth = tileset.tileWidth;
|
||||||
|
@ -185160,7 +185179,6 @@ var DynamicTilemapLayerWebGLRenderer = function (renderer, src, interpolationPer
|
||||||
|
|
||||||
var tw = frameWidth * 0.5;
|
var tw = frameWidth * 0.5;
|
||||||
var th = frameHeight * 0.5;
|
var th = frameHeight * 0.5;
|
||||||
|
|
||||||
|
|
||||||
var tint = getTint(tile.tint, alpha * tile.alpha);
|
var tint = getTint(tile.tint, alpha * tile.alpha);
|
||||||
|
|
||||||
|
@ -185287,7 +185305,7 @@ var DynamicTilemapLayerCanvasRenderer = function (renderer, src, interpolationPe
|
||||||
var width = tile.width;
|
var width = tile.width;
|
||||||
var height = tile.width;
|
var height = tile.width;
|
||||||
|
|
||||||
if (src.layer.orientation === 'isometric')
|
if (src.layer.orientation === 'isometric' || src.layer.orientation === 'staggered')
|
||||||
{
|
{
|
||||||
// we use the tileset width and height because in isometric maps the tileset's height is often different from the tilemap's.
|
// we use the tileset width and height because in isometric maps the tileset's height is often different from the tilemap's.
|
||||||
width = tileset.tileWidth;
|
width = tileset.tileWidth;
|
||||||
|
@ -185463,6 +185481,7 @@ module.exports = StaticTilemapLayerWebGLRenderer;
|
||||||
var StaticTilemapLayerCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix)
|
var StaticTilemapLayerCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix)
|
||||||
{
|
{
|
||||||
src.cull(camera);
|
src.cull(camera);
|
||||||
|
|
||||||
var renderTiles = src.culledTiles;
|
var renderTiles = src.culledTiles;
|
||||||
var tileCount = renderTiles.length;
|
var tileCount = renderTiles.length;
|
||||||
|
|
||||||
|
@ -185598,6 +185617,7 @@ GameObjectCreator.register('tilemap', function (config)
|
||||||
{
|
{
|
||||||
// Defaults are applied in ParseToTilemap
|
// Defaults are applied in ParseToTilemap
|
||||||
var c = (config !== undefined) ? config : {};
|
var c = (config !== undefined) ? config : {};
|
||||||
|
|
||||||
return ParseToTilemap(
|
return ParseToTilemap(
|
||||||
this.scene,
|
this.scene,
|
||||||
c.key,
|
c.key,
|
||||||
|
|
2
dist/phaser.min.js
vendored
2
dist/phaser.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -22,6 +22,8 @@
|
||||||
"buildfb": "webpack --config config/webpack.fb.config.js",
|
"buildfb": "webpack --config config/webpack.fb.config.js",
|
||||||
"watchfb": "webpack --config config/webpack.fb.config.js --watch",
|
"watchfb": "webpack --config config/webpack.fb.config.js --watch",
|
||||||
"dist": "webpack --config config/webpack.dist.config.js",
|
"dist": "webpack --config config/webpack.dist.config.js",
|
||||||
|
"distT": "webpack --config config/webpack.dist.config.js && npm run toT",
|
||||||
|
"toT": "@powershell Copy-Item ./dist/phaser.min.js ../phasertest/phaser.min.js",
|
||||||
"distfb": "webpack --config config/webpack.fb.dist.config.js",
|
"distfb": "webpack --config config/webpack.fb.dist.config.js",
|
||||||
"distfull": "npm run dist && npm run distfb",
|
"distfull": "npm run dist && npm run distfb",
|
||||||
"plugin.cam3d": "webpack --config plugins/camera3d/webpack.config.js",
|
"plugin.cam3d": "webpack --config plugins/camera3d/webpack.config.js",
|
||||||
|
|
|
@ -714,7 +714,6 @@ var Tile = new Class({
|
||||||
this.pixelX = this.x * this.baseWidth;
|
this.pixelX = this.x * this.baseWidth;
|
||||||
this.pixelY = this.y * this.baseHeight;
|
this.pixelY = this.y * this.baseHeight;
|
||||||
|
|
||||||
// console.log("orthopix "+this.pixelX+","+this.pixelY)
|
|
||||||
}
|
}
|
||||||
else if (this.layer.orientation === 'isometric')
|
else if (this.layer.orientation === 'isometric')
|
||||||
{
|
{
|
||||||
|
@ -723,11 +722,12 @@ var Tile = new Class({
|
||||||
this.pixelX = (this.x - this.y) * this.baseWidth * 0.5;
|
this.pixelX = (this.x - this.y) * this.baseWidth * 0.5;
|
||||||
this.pixelY = (this.x + this.y) * this.baseHeight * 0.5;
|
this.pixelY = (this.x + this.y) * this.baseHeight * 0.5;
|
||||||
|
|
||||||
// console.log("isopix from",this.x, this.y,"to", this.pixelX+","+this.pixelY)
|
|
||||||
}
|
}
|
||||||
else
|
else if (this.layer.orientation === 'staggered')
|
||||||
{
|
{
|
||||||
// console.warn("this map orientation is is.layer.orientation)
|
this.pixelX = this.x * this.baseWidth + this.y % 2 * (this.baseWidth / 2);
|
||||||
|
this.pixelY = this.y * (this.baseHeight / 2);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// this.pixelY = this.y * this.baseHeight - (this.height - this.baseHeight);
|
// this.pixelY = this.y * this.baseHeight - (this.height - this.baseHeight);
|
||||||
|
|
|
@ -49,7 +49,7 @@ var CullTiles = function (layer, camera, outputArray, renderOrder)
|
||||||
var inIsoBounds = function () { return true; };
|
var inIsoBounds = function () { return true; };
|
||||||
if (!tilemapLayer.skipCull && tilemapLayer.scrollFactorX === 1 && tilemapLayer.scrollFactorY === 1)
|
if (!tilemapLayer.skipCull && tilemapLayer.scrollFactorX === 1 && tilemapLayer.scrollFactorY === 1)
|
||||||
{
|
{
|
||||||
if (layer.orientation === 'orthogonal')
|
if (layer.orientation === 'orthogonal' || layer.orientation === 'staggered')
|
||||||
{
|
{
|
||||||
// Camera world view bounds, snapped for scaled tile size
|
// Camera world view bounds, snapped for scaled tile size
|
||||||
// Cull Padding values are given in tiles, not pixels
|
// Cull Padding values are given in tiles, not pixels
|
||||||
|
@ -62,6 +62,7 @@ var CullTiles = function (layer, camera, outputArray, renderOrder)
|
||||||
drawLeft = Math.max(0, boundsLeft);
|
drawLeft = Math.max(0, boundsLeft);
|
||||||
drawRight = Math.min(mapWidth, boundsRight);
|
drawRight = Math.min(mapWidth, boundsRight);
|
||||||
drawTop = Math.max(0, boundsTop);
|
drawTop = Math.max(0, boundsTop);
|
||||||
|
|
||||||
drawBottom = Math.min(mapHeight, boundsBottom);
|
drawBottom = Math.min(mapHeight, boundsBottom);
|
||||||
}
|
}
|
||||||
else if (layer.orientation === 'isometric')
|
else if (layer.orientation === 'isometric')
|
||||||
|
@ -84,7 +85,7 @@ var CullTiles = function (layer, camera, outputArray, renderOrder)
|
||||||
var tile;
|
var tile;
|
||||||
|
|
||||||
|
|
||||||
if (layer.orientation === 'orthogonal')
|
if (layer.orientation === 'orthogonal' || layer.orientation === 'staggered')
|
||||||
{
|
{
|
||||||
|
|
||||||
if (renderOrder === 0)
|
if (renderOrder === 0)
|
||||||
|
|
|
@ -43,7 +43,7 @@ var TileToWorldXY = function (tileX, tileY, point, camera, layer)
|
||||||
point.x = TileToWorldX(tileX, camera, layer, orientation);
|
point.x = TileToWorldX(tileX, camera, layer, orientation);
|
||||||
point.y = TileToWorldY(tileY, camera, layer, orientation);
|
point.y = TileToWorldY(tileY, camera, layer, orientation);
|
||||||
}
|
}
|
||||||
else if (orientation === 'isometric')
|
else if (orientation === 'isometric' || orientation === 'staggered')
|
||||||
{
|
{
|
||||||
|
|
||||||
var layerWorldX = 0;
|
var layerWorldX = 0;
|
||||||
|
@ -59,9 +59,18 @@ var TileToWorldXY = function (tileX, tileY, point, camera, layer)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (orientation === 'isometric')
|
||||||
point.x = layerWorldX + (tileX - tileY) * (tileWidth / 2);
|
{
|
||||||
point.y = layerWorldY + (tileX + tileY) * (tileHeight / 2);
|
point.x = layerWorldX + (tileX - tileY) * (tileWidth / 2);
|
||||||
|
point.y = layerWorldY + (tileX + tileY) * (tileHeight / 2);
|
||||||
|
}
|
||||||
|
else if (orientation === 'staggered')
|
||||||
|
{
|
||||||
|
// todo
|
||||||
|
point.x = layerWorldX + tileX * tileWidth + tileY % 2 * (tileWidth / 2);
|
||||||
|
point.y = layerWorldY + tileY * (tileHeight / 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ var WorldToTileXY = function (worldX, worldY, snapToFloor, point, camera, layer)
|
||||||
point.x = WorldToTileX(worldX, snapToFloor, camera, layer, orientation);
|
point.x = WorldToTileX(worldX, snapToFloor, camera, layer, orientation);
|
||||||
point.y = WorldToTileY(worldY, snapToFloor, camera, layer, orientation);
|
point.y = WorldToTileY(worldY, snapToFloor, camera, layer, orientation);
|
||||||
}
|
}
|
||||||
else if (orientation === 'isometric')
|
else if (orientation === 'isometric' || orientation === 'staggered')
|
||||||
{
|
{
|
||||||
|
|
||||||
var tileWidth = layer.baseTileWidth;
|
var tileWidth = layer.baseTileWidth;
|
||||||
|
@ -61,18 +61,39 @@ var WorldToTileXY = function (worldX, worldY, snapToFloor, point, camera, layer)
|
||||||
|
|
||||||
tileWidth *= tilemapLayer.scaleX;
|
tileWidth *= tilemapLayer.scaleX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (orientation === 'isometric')
|
||||||
|
{
|
||||||
|
point.x = snapToFloor
|
||||||
|
? Math.floor((worldX / (tileWidth / 2) + worldY / (tileHeight / 2)) / 2)
|
||||||
|
: ((worldX / (tileWidth / 2) + worldY / (tileHeight / 2)) / 2);
|
||||||
|
|
||||||
point.x = snapToFloor
|
point.y = snapToFloor
|
||||||
? Math.floor((worldX / (tileWidth / 2) + worldY / (tileHeight / 2)) / 2)
|
? Math.floor((worldY / (tileHeight / 2) - worldX / (tileWidth / 2)) / 2)
|
||||||
: ((worldX / (tileWidth / 2) + worldY / (tileHeight / 2)) / 2);
|
: ((worldY / (tileHeight / 2) - worldX / (tileWidth / 2)) / 2);
|
||||||
|
}
|
||||||
point.y = snapToFloor
|
if (orientation === 'orthogonal')
|
||||||
? Math.floor((worldY / (tileHeight / 2) - worldX / (tileWidth / 2)) / 2)
|
{
|
||||||
: ((worldY / (tileHeight / 2) - worldX / (tileWidth / 2)) / 2);
|
point.x = snapToFloor
|
||||||
|
? Math.floor(worldX / tileWidth)
|
||||||
|
: worldX / tileWidth;
|
||||||
|
point.y = snapToFloor
|
||||||
|
? Math.floor(worldY / tileHeight)
|
||||||
|
: worldY / tileHeight;
|
||||||
|
}
|
||||||
|
else if (orientation === 'staggered')
|
||||||
|
{
|
||||||
|
// implement world to tile staggered
|
||||||
|
point.y = snapToFloor
|
||||||
|
? Math.floor((worldY / (tileHeight / 2)))
|
||||||
|
: (worldY / (tileHeight / 2));
|
||||||
|
point.x = snapToFloor
|
||||||
|
? Math.floor((worldX / tileWidth) - (point.y % 2))
|
||||||
|
: (worldX / tileWidth) - (point.y % 2);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return point;
|
return point;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,7 @@ var DynamicTilemapLayerCanvasRenderer = function (renderer, src, interpolationPe
|
||||||
var width = tile.width;
|
var width = tile.width;
|
||||||
var height = tile.width;
|
var height = tile.width;
|
||||||
|
|
||||||
if (src.layer.orientation === 'isometric')
|
if (src.layer.orientation === 'isometric' || src.layer.orientation === 'staggered')
|
||||||
{
|
{
|
||||||
// we use the tileset width and height because in isometric maps the tileset's height is often different from the tilemap's.
|
// we use the tileset width and height because in isometric maps the tileset's height is often different from the tilemap's.
|
||||||
width = tileset.tileWidth;
|
width = tileset.tileWidth;
|
||||||
|
|
|
@ -78,7 +78,7 @@ var DynamicTilemapLayerWebGLRenderer = function (renderer, src, interpolationPer
|
||||||
var frameWidth = 0;
|
var frameWidth = 0;
|
||||||
var frameHeight = 0;
|
var frameHeight = 0;
|
||||||
|
|
||||||
if (src.layer.orientation === 'isometric')
|
if (src.layer.orientation === 'isometric' || src.layer.orientation === 'staggered')
|
||||||
{
|
{
|
||||||
// we use the tileset width and height because in isometric maps the tileset's height is often different from the tilemap's.
|
// we use the tileset width and height because in isometric maps the tileset's height is often different from the tilemap's.
|
||||||
frameWidth = tileset.tileWidth;
|
frameWidth = tileset.tileWidth;
|
||||||
|
|
|
@ -32,7 +32,7 @@ var AssignTileProperties = require('./AssignTileProperties');
|
||||||
*/
|
*/
|
||||||
var ParseJSONTiled = function (name, json, insertNull)
|
var ParseJSONTiled = function (name, json, insertNull)
|
||||||
{
|
{
|
||||||
if (json.orientation === 'isometric')
|
if (json.orientation === 'isometric' || json.orientation === 'staggered')
|
||||||
{
|
{
|
||||||
console.warn('isometric map types are WIP in this version of Phaser');
|
console.warn('isometric map types are WIP in this version of Phaser');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue