need to compare across commits to understand regression regarding this.x

This commit is contained in:
Svipal 2020-01-27 20:12:53 +01:00
parent 208c77f3fd
commit 95d2ff9996
18 changed files with 5087 additions and 4021 deletions

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

4816
dist/phaser.js vendored

File diff suppressed because it is too large Load diff

2
dist/phaser.min.js vendored

File diff suppressed because one or more lines are too long

View file

@ -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",

View file

@ -77,6 +77,7 @@ var Tile = new Class({
* @since 3.0.0 * @since 3.0.0
*/ */
this.x = x; this.x = x;
console.log("tile x : " + x)
/** /**
* The y map coordinate of this tile in tile units. * The y map coordinate of this tile in tile units.
@ -284,6 +285,7 @@ var Tile = new Class({
* @since 3.2.PR_svipal * @since 3.2.PR_svipal
*/ */
this.orientation = orientation this.orientation = orientation
console.log("tile orientation : "+this.orientation)
}, },
/** /**
@ -719,14 +721,16 @@ var Tile = new Class({
// Tiled places tiles on a grid of baseWidth x baseHeight. The origin for a tile is the // Tiled places tiles on a grid of baseWidth x baseHeight. The origin for a tile is the
// bottom left, while the Phaser renderer assumes the origin is the top left. The y // bottom left, while the Phaser renderer assumes the origin is the top left. The y
// coordinate needs to be adjusted by the difference. // coordinate needs to be adjusted by the difference.
if (this.orientation = "orthogonal") { if (this.orientation === "orthogonal" || true) {
this.pixelX = this.x * this.baseWidth; this.pixelX = this.x * this.baseWidth;
this.pixelY = this.y * this.baseHeight; this.pixelY = this.y * this.baseHeight;
} else if (this.orientation = "isometric") { console.log("orthopix "+this.pixelX+","+this.pixelY)
console.log("isopix") } else /*if (this.orientation === "isometric")*/ {
// once we get the 'top' of the losange we need to remove half of the tile width. // once we get the 'top' of the losange we need to remove half of the tile width.
this.pixelX = (this.x - this.y) * this.baseWidth / 2; this.pixelX = (this.x - this.y) * this.baseWidth *0.5;
this.pixelY = (this.x + this.y) * this.baseHeight / 2; this.pixelY = (this.x + this.y) * this.baseHeight *0.5;
console.log("isopix "+this.pixelX+","+this.pixelY)
} }
// this.pixelY = this.y * this.baseHeight - (this.height - this.baseHeight); // this.pixelY = this.y * this.baseHeight - (this.height - this.baseHeight);

View file

@ -135,6 +135,7 @@ var Tilemap = new Class({
* @since 3.0.0 * @since 3.0.0
*/ */
this.orientation = mapData.orientation; this.orientation = mapData.orientation;
console.log("map orientation :" + this.orientation)
/** /**
* The render (draw) order of the map data (as specified in Tiled), usually 'right-down'. * The render (draw) order of the map data (as specified in Tiled), usually 'right-down'.

View file

@ -24,10 +24,11 @@ var SetTileCollision = require('./SetTileCollision');
* @param {integer} tileY - The y coordinate, in tiles, not pixels. * @param {integer} tileY - The y coordinate, in tiles, not pixels.
* @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated.
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
* @param {string} orientation - The Tilemap's orientation
* *
* @return {Phaser.Tilemaps.Tile} The Tile object that was created or added to this map. * @return {Phaser.Tilemaps.Tile} The Tile object that was created or added to this map.
*/ */
var PutTileAt = function (tile, tileX, tileY, recalculateFaces, layer) var PutTileAt = function (tile, tileX, tileY, recalculateFaces, layer, orientation)
{ {
if (!IsInLayerBounds(tileX, tileY, layer)) { return null; } if (!IsInLayerBounds(tileX, tileY, layer)) { return null; }
if (recalculateFaces === undefined) { recalculateFaces = true; } if (recalculateFaces === undefined) { recalculateFaces = true; }
@ -39,7 +40,7 @@ var PutTileAt = function (tile, tileX, tileY, recalculateFaces, layer)
{ {
if (layer.data[tileY][tileX] === null) if (layer.data[tileY][tileX] === null)
{ {
layer.data[tileY][tileX] = new Tile(layer, tile.index, tileX, tileY, tile.width, tile.height); layer.data[tileY][tileX] = new Tile(layer, tile.index, tileX, tileY, tile.width, tile.height, orientation);
} }
layer.data[tileY][tileX].copy(tile); layer.data[tileY][tileX].copy(tile);
} }

View file

@ -25,7 +25,7 @@ var WorldToTileY = require('./WorldToTileY');
* @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.
* @param {string} orientation - The Tilemap's orientation * @param {string} orientation - The Tilemap's orientation
* * //Instinct : mistake to put it there
* @return {Phaser.Tilemaps.Tile} The Tile object that was created or added to this map. * @return {Phaser.Tilemaps.Tile} The Tile object that was created or added to this map.
*/ */
var PutTileAtWorldXY = function (tile, worldX, worldY, recalculateFaces, camera, layer, orientation) var PutTileAtWorldXY = function (tile, worldX, worldY, recalculateFaces, camera, layer, orientation)

View file

@ -23,8 +23,10 @@ var PutTileAt = require('./PutTileAt');
* @param {integer} tileY - The y coordinate, in tiles, not pixels. * @param {integer} tileY - The y coordinate, in tiles, not pixels.
* @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated.
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
* @param {string} orientation - The Tilemap's orientation
*
*/ */
var PutTilesAt = function (tilesArray, tileX, tileY, recalculateFaces, layer) var PutTilesAt = function (tilesArray, tileX, tileY, recalculateFaces, layer, orientation)
{ {
if (!Array.isArray(tilesArray)) { return null; } if (!Array.isArray(tilesArray)) { return null; }
if (recalculateFaces === undefined) { recalculateFaces = true; } if (recalculateFaces === undefined) { recalculateFaces = true; }
@ -43,7 +45,7 @@ var PutTilesAt = function (tilesArray, tileX, tileY, recalculateFaces, layer)
for (var tx = 0; tx < width; tx++) for (var tx = 0; tx < width; tx++)
{ {
var tile = tilesArray[ty][tx]; var tile = tilesArray[ty][tx];
PutTileAt(tile, tileX + tx, tileY + ty, false, layer); PutTileAt(tile, tileX + tx, tileY + ty, false, layer, orientation);
} }
} }

View file

@ -34,7 +34,7 @@ var WorldToTileXY = function (worldX, worldY, snapToFloor, point, camera, layer,
if (orientation === "orthogonal") { if (orientation === "orthogonal") {
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') {
var tileWidth = layer.baseTileWidth; var tileWidth = layer.baseTileWidth;
var tileHeight = layer.baseTileHeight; var tileHeight = layer.baseTileHeight;

View file

@ -750,7 +750,7 @@ var DynamicTilemapLayer = new Class({
*/ */
putTileAt: function (tile, tileX, tileY, recalculateFaces) putTileAt: function (tile, tileX, tileY, recalculateFaces)
{ {
return TilemapComponents.PutTileAt(tile, tileX, tileY, recalculateFaces, this.layer); return TilemapComponents.PutTileAt(tile, tileX, tileY, recalculateFaces, this.layer, this.tilemap.orientation);
}, },
/** /**
@ -794,7 +794,7 @@ var DynamicTilemapLayer = new Class({
*/ */
putTilesAt: function (tilesArray, tileX, tileY, recalculateFaces) putTilesAt: function (tilesArray, tileX, tileY, recalculateFaces)
{ {
TilemapComponents.PutTilesAt(tilesArray, tileX, tileY, recalculateFaces, this.layer); TilemapComponents.PutTilesAt(tilesArray, tileX, tileY, recalculateFaces, this.layer, this.tilemap.orientation);
return this; return this;
}, },

View file

@ -117,7 +117,7 @@ var MapData = new Class({
* @since 3.0.0 * @since 3.0.0
*/ */
this.orientation = GetFastValue(config, 'orientation', 'orthogonal'); this.orientation = GetFastValue(config, 'orientation', 'orthogonal');
console.log("map data orientation : " + this.orientation)
/** /**
* Determines the draw order of tilemap. Default is right-down * Determines the draw order of tilemap. Default is right-down
* *

View file

@ -34,7 +34,7 @@ var Parse2DArray = function (name, data, tileWidth, tileHeight, insertNull)
tileWidth: tileWidth, tileWidth: tileWidth,
tileHeight: tileHeight tileHeight: tileHeight
}); });
console.log("parsing 2D array")
var mapData = new MapData({ var mapData = new MapData({
name: name, name: name,
tileWidth: tileWidth, tileWidth: tileWidth,

View file

@ -32,11 +32,14 @@ var AssignTileProperties = require('./AssignTileProperties');
*/ */
var ParseJSONTiled = function (name, json, insertNull) var ParseJSONTiled = function (name, json, insertNull)
{ {
// if (json.orientation !== 'orthogonal') if (json.orientation == 'isometric')
// { {
// console.warn('Only orthogonal map types are supported in this version of Phaser'); console.warn('isometric map types are WIP in this version of Phaser');
// return null;
// } } else if (json.orientation == 'orthogonal') {
console.warn('Only orthogonal map types are supported in this version of Phaser');
return null;
}
// Map data will consist of: layers, objects, images, tilesets, sizes // Map data will consist of: layers, objects, images, tilesets, sizes
var mapData = new MapData({ var mapData = new MapData({

View file

@ -160,7 +160,7 @@ var ParseTileLayers = function (json, insertNull)
if (gidInfo.gid > 0) if (gidInfo.gid > 0)
{ {
tile = new Tile(layerData, gidInfo.gid, newOffsetX, newOffsetY, json.tilewidth, tile = new Tile(layerData, gidInfo.gid, newOffsetX, newOffsetY, json.tilewidth,
json.tileheight); json.tileheight,json.orientation);
// Turning Tiled's FlippedHorizontal, FlippedVertical and FlippedAntiDiagonal // Turning Tiled's FlippedHorizontal, FlippedVertical and FlippedAntiDiagonal
// propeties into flipX, flipY and rotation // propeties into flipX, flipY and rotation
@ -173,7 +173,7 @@ var ParseTileLayers = function (json, insertNull)
{ {
blankTile = insertNull blankTile = insertNull
? null ? null
: new Tile(layerData, -1, newOffsetX, newOffsetY, json.tilewidth, json.tileheight); : new Tile(layerData, -1, newOffsetX, newOffsetY, json.tilewidth, json.tileheight,json.orientation);
output[newOffsetY][newOffsetX] = blankTile; output[newOffsetY][newOffsetX] = blankTile;
} }
@ -214,7 +214,7 @@ var ParseTileLayers = function (json, insertNull)
if (gidInfo.gid > 0) if (gidInfo.gid > 0)
{ {
tile = new Tile(layerData, gidInfo.gid, x, output.length, json.tilewidth, tile = new Tile(layerData, gidInfo.gid, x, output.length, json.tilewidth,
json.tileheight); json.tileheight, json.orientation);
// Turning Tiled's FlippedHorizontal, FlippedVertical and FlippedAntiDiagonal // Turning Tiled's FlippedHorizontal, FlippedVertical and FlippedAntiDiagonal
// propeties into flipX, flipY and rotation // propeties into flipX, flipY and rotation
@ -227,7 +227,7 @@ var ParseTileLayers = function (json, insertNull)
{ {
blankTile = insertNull blankTile = insertNull
? null ? null
: new Tile(layerData, -1, x, output.length, json.tilewidth, json.tileheight); : new Tile(layerData, -1, x, output.length, json.tilewidth, json.tileheight, json.orientation);
row.push(blankTile); row.push(blankTile);
} }

View file

@ -22,7 +22,7 @@
var StaticTilemapLayerCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) var StaticTilemapLayerCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix)
{ {
src.cull(camera); src.cull(camera);
console.log("canvas renderer")
var renderTiles = src.culledTiles; var renderTiles = src.culledTiles;
var tileCount = renderTiles.length; var tileCount = renderTiles.length;

View file

@ -23,6 +23,7 @@
*/ */
var StaticTilemapLayerWebGLRenderer = function (renderer, src, interpolationPercentage, camera) var StaticTilemapLayerWebGLRenderer = function (renderer, src, interpolationPercentage, camera)
{ {
console.log("webgl renderer")
var tilesets = src.tileset; var tilesets = src.tileset;
var pipeline = src.pipeline; var pipeline = src.pipeline;