mirror of
https://github.com/photonstorm/phaser
synced 2024-12-23 11:33:28 +00:00
fixed problems with putting tiles from null tiles
This commit is contained in:
parent
a8b60cf946
commit
aaf512b9cd
10 changed files with 65 additions and 64 deletions
34
dist/phaser-arcade-physics.js
vendored
34
dist/phaser-arcade-physics.js
vendored
|
@ -12226,7 +12226,6 @@ var Tile = new Class({
|
||||||
|
|
||||||
function Tile (layer, index, x, y, width, height, baseWidth, baseHeight )
|
function Tile (layer, index, x, y, width, height, baseWidth, baseHeight )
|
||||||
{
|
{
|
||||||
console.log(this)
|
|
||||||
/**
|
/**
|
||||||
* The LayerData in the Tilemap data that this tile belongs to.
|
* The LayerData in the Tilemap data that this tile belongs to.
|
||||||
*
|
*
|
||||||
|
@ -12886,7 +12885,7 @@ var Tile = new Class({
|
||||||
*/
|
*/
|
||||||
updatePixelXY: function ()
|
updatePixelXY: function ()
|
||||||
{
|
{
|
||||||
if (this.layer.orientation === "orthogonal") {
|
if (this.layer.orientation === "orthogonal") {
|
||||||
// In orthogonal mode, Tiled places tiles on a grid of baseWidth x baseHeight. The origin for a tile is the
|
// In orthogonal mode, 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.
|
||||||
|
@ -12894,14 +12893,14 @@ var Tile = new Class({
|
||||||
this.pixelY = this.y * this.baseHeight;
|
this.pixelY = this.y * this.baseHeight;
|
||||||
// console.log("orthopix "+this.pixelX+","+this.pixelY)
|
// console.log("orthopix "+this.pixelX+","+this.pixelY)
|
||||||
} else if (this.layer.orientation === "isometric" ) {
|
} else if (this.layer.orientation === "isometric" ) {
|
||||||
// for the image to be centered we have to move the image to the right with the camera !
|
// reminder : for the tilemap to be centered we have to move the image to the right with the camera !
|
||||||
// this is crucial for wordtotile, tiletoworld to work.
|
// this is crucial for wordtotile, tiletoworld to work.
|
||||||
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 "+this.pixelX+","+this.pixelY)
|
// console.log("isopix from",this.x, this.y,"to", this.pixelX+","+this.pixelY)
|
||||||
} else {
|
} else {
|
||||||
console.warn("this map orientation is not supported in this version of phaser")
|
// console.warn("this map orientation is not supported in this version of phaser")
|
||||||
console.log("tile orientation 3: "+this.layer.orientation)
|
// console.log("tile orientation 3: "+this.layer.orientation)
|
||||||
}
|
}
|
||||||
|
|
||||||
// this.pixelY = this.y * this.baseHeight - (this.height - this.baseHeight);
|
// this.pixelY = this.y * this.baseHeight - (this.height - this.baseHeight);
|
||||||
|
@ -47399,9 +47398,10 @@ 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, tile.width, tile.height);
|
layer.data[tileY][tileX] = new Tile(layer, tile.index, tileX, tileY, layer.tileWidth, layer.tileHeight);
|
||||||
}
|
}
|
||||||
layer.data[tileY][tileX].copy(tile);
|
layer.data[tileY][tileX].copy(tile);
|
||||||
}
|
}
|
||||||
|
@ -47410,6 +47410,7 @@ 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
|
||||||
|
@ -47417,7 +47418,6 @@ var PutTileAt = function (tile, tileX, tileY, recalculateFaces, layer)
|
||||||
layer.data[tileY][tileX].index = index;
|
layer.data[tileY][tileX].index = index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Updating colliding flag on the new tile
|
// Updating colliding flag on the new tile
|
||||||
var newTile = layer.data[tileY][tileX];
|
var newTile = layer.data[tileY][tileX];
|
||||||
var collides = layer.collideIndexes.indexOf(newTile.index) !== -1;
|
var collides = layer.collideIndexes.indexOf(newTile.index) !== -1;
|
||||||
|
@ -107144,6 +107144,9 @@ var DynamicTilemapLayer = new Class({
|
||||||
this.setSize(tilemap.tileWidth * this.layer.width, tilemap.tileHeight * this.layer.height);
|
this.setSize(tilemap.tileWidth * this.layer.width, tilemap.tileHeight * this.layer.height);
|
||||||
|
|
||||||
this.initPipeline('TextureTintPipeline');
|
this.initPipeline('TextureTintPipeline');
|
||||||
|
|
||||||
|
console.log("layer sizes")
|
||||||
|
console.log(this.layer.tileWidth,this.layer.tileHeight)
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -177320,7 +177323,6 @@ var DynamicTilemapLayerCanvasRenderer = function (renderer, src, interpolationPe
|
||||||
|
|
||||||
var renderTiles = src.culledTiles;
|
var renderTiles = src.culledTiles;
|
||||||
var tileCount = renderTiles.length;
|
var tileCount = renderTiles.length;
|
||||||
|
|
||||||
if (tileCount === 0)
|
if (tileCount === 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -177370,8 +177372,8 @@ var DynamicTilemapLayerCanvasRenderer = function (renderer, src, interpolationPe
|
||||||
|
|
||||||
for (var i = 0; i < tileCount; i++)
|
for (var i = 0; i < tileCount; i++)
|
||||||
{
|
{
|
||||||
var tile = renderTiles[i];
|
|
||||||
|
|
||||||
|
var tile = renderTiles[i];
|
||||||
var tileset = gidMap[tile.index];
|
var tileset = gidMap[tile.index];
|
||||||
|
|
||||||
if (!tileset)
|
if (!tileset)
|
||||||
|
@ -177380,21 +177382,20 @@ var DynamicTilemapLayerCanvasRenderer = function (renderer, src, interpolationPe
|
||||||
}
|
}
|
||||||
|
|
||||||
var image = tileset.image.getSourceImage();
|
var image = tileset.image.getSourceImage();
|
||||||
|
|
||||||
var tileTexCoords = tileset.getTileTextureCoordinates(tile.index);
|
var tileTexCoords = tileset.getTileTextureCoordinates(tile.index);
|
||||||
|
|
||||||
if (tileTexCoords)
|
if (tileTexCoords)
|
||||||
{
|
{
|
||||||
var width = 0;
|
var width = tile.width;
|
||||||
var height = 0;
|
var height = tile.width;
|
||||||
|
|
||||||
if (src.layer.orientation === "isometric") {
|
if (src.layer.orientation === "isometric") {
|
||||||
// here we use the tileset width and height to fix problems with isometric map types
|
// here we use the tileset width and height to fix problems with isometric map types
|
||||||
width = tileset.tileWidth;
|
width = tileset.tileWidth;
|
||||||
width = tileset.tileHeight;
|
width = tileset.tileHeight;
|
||||||
} else {
|
|
||||||
width = tile.width;
|
|
||||||
height = tile.width
|
|
||||||
}
|
}
|
||||||
|
|
||||||
halfWidth = width / 2;
|
halfWidth = width / 2;
|
||||||
halfHeight = height / 2;
|
halfHeight = height / 2;
|
||||||
|
|
||||||
|
@ -177417,13 +177418,14 @@ var DynamicTilemapLayerCanvasRenderer = function (renderer, src, interpolationPe
|
||||||
ctx.drawImage(
|
ctx.drawImage(
|
||||||
image,
|
image,
|
||||||
tileTexCoords.x, tileTexCoords.y,
|
tileTexCoords.x, tileTexCoords.y,
|
||||||
width, height,
|
tileset.tileWidth, tileset.tileHeight,
|
||||||
-halfWidth, -halfHeight,
|
-halfWidth, -halfHeight,
|
||||||
width, height
|
width, height
|
||||||
);
|
);
|
||||||
|
|
||||||
ctx.restore();
|
ctx.restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.restore();
|
ctx.restore();
|
||||||
|
|
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
34
dist/phaser.js
vendored
34
dist/phaser.js
vendored
|
@ -14150,7 +14150,6 @@ var Tile = new Class({
|
||||||
|
|
||||||
function Tile (layer, index, x, y, width, height, baseWidth, baseHeight )
|
function Tile (layer, index, x, y, width, height, baseWidth, baseHeight )
|
||||||
{
|
{
|
||||||
console.log(this)
|
|
||||||
/**
|
/**
|
||||||
* The LayerData in the Tilemap data that this tile belongs to.
|
* The LayerData in the Tilemap data that this tile belongs to.
|
||||||
*
|
*
|
||||||
|
@ -14810,7 +14809,7 @@ var Tile = new Class({
|
||||||
*/
|
*/
|
||||||
updatePixelXY: function ()
|
updatePixelXY: function ()
|
||||||
{
|
{
|
||||||
if (this.layer.orientation === "orthogonal") {
|
if (this.layer.orientation === "orthogonal") {
|
||||||
// In orthogonal mode, Tiled places tiles on a grid of baseWidth x baseHeight. The origin for a tile is the
|
// In orthogonal mode, 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.
|
||||||
|
@ -14818,14 +14817,14 @@ var Tile = new Class({
|
||||||
this.pixelY = this.y * this.baseHeight;
|
this.pixelY = this.y * this.baseHeight;
|
||||||
// console.log("orthopix "+this.pixelX+","+this.pixelY)
|
// console.log("orthopix "+this.pixelX+","+this.pixelY)
|
||||||
} else if (this.layer.orientation === "isometric" ) {
|
} else if (this.layer.orientation === "isometric" ) {
|
||||||
// for the image to be centered we have to move the image to the right with the camera !
|
// reminder : for the tilemap to be centered we have to move the image to the right with the camera !
|
||||||
// this is crucial for wordtotile, tiletoworld to work.
|
// this is crucial for wordtotile, tiletoworld to work.
|
||||||
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 "+this.pixelX+","+this.pixelY)
|
// console.log("isopix from",this.x, this.y,"to", this.pixelX+","+this.pixelY)
|
||||||
} else {
|
} else {
|
||||||
console.warn("this map orientation is not supported in this version of phaser")
|
// console.warn("this map orientation is not supported in this version of phaser")
|
||||||
console.log("tile orientation 3: "+this.layer.orientation)
|
// console.log("tile orientation 3: "+this.layer.orientation)
|
||||||
}
|
}
|
||||||
|
|
||||||
// this.pixelY = this.y * this.baseHeight - (this.height - this.baseHeight);
|
// this.pixelY = this.y * this.baseHeight - (this.height - this.baseHeight);
|
||||||
|
@ -51689,9 +51688,10 @@ 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, tile.width, tile.height);
|
layer.data[tileY][tileX] = new Tile(layer, tile.index, tileX, tileY, layer.tileWidth, layer.tileHeight);
|
||||||
}
|
}
|
||||||
layer.data[tileY][tileX].copy(tile);
|
layer.data[tileY][tileX].copy(tile);
|
||||||
}
|
}
|
||||||
|
@ -51700,6 +51700,7 @@ 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
|
||||||
|
@ -51707,7 +51708,6 @@ var PutTileAt = function (tile, tileX, tileY, recalculateFaces, layer)
|
||||||
layer.data[tileY][tileX].index = index;
|
layer.data[tileY][tileX].index = index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Updating colliding flag on the new tile
|
// Updating colliding flag on the new tile
|
||||||
var newTile = layer.data[tileY][tileX];
|
var newTile = layer.data[tileY][tileX];
|
||||||
var collides = layer.collideIndexes.indexOf(newTile.index) !== -1;
|
var collides = layer.collideIndexes.indexOf(newTile.index) !== -1;
|
||||||
|
@ -111955,6 +111955,9 @@ var DynamicTilemapLayer = new Class({
|
||||||
this.setSize(tilemap.tileWidth * this.layer.width, tilemap.tileHeight * this.layer.height);
|
this.setSize(tilemap.tileWidth * this.layer.width, tilemap.tileHeight * this.layer.height);
|
||||||
|
|
||||||
this.initPipeline('TextureTintPipeline');
|
this.initPipeline('TextureTintPipeline');
|
||||||
|
|
||||||
|
console.log("layer sizes")
|
||||||
|
console.log(this.layer.tileWidth,this.layer.tileHeight)
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -185246,7 +185249,6 @@ var DynamicTilemapLayerCanvasRenderer = function (renderer, src, interpolationPe
|
||||||
|
|
||||||
var renderTiles = src.culledTiles;
|
var renderTiles = src.culledTiles;
|
||||||
var tileCount = renderTiles.length;
|
var tileCount = renderTiles.length;
|
||||||
|
|
||||||
if (tileCount === 0)
|
if (tileCount === 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -185296,8 +185298,8 @@ var DynamicTilemapLayerCanvasRenderer = function (renderer, src, interpolationPe
|
||||||
|
|
||||||
for (var i = 0; i < tileCount; i++)
|
for (var i = 0; i < tileCount; i++)
|
||||||
{
|
{
|
||||||
var tile = renderTiles[i];
|
|
||||||
|
|
||||||
|
var tile = renderTiles[i];
|
||||||
var tileset = gidMap[tile.index];
|
var tileset = gidMap[tile.index];
|
||||||
|
|
||||||
if (!tileset)
|
if (!tileset)
|
||||||
|
@ -185306,21 +185308,20 @@ var DynamicTilemapLayerCanvasRenderer = function (renderer, src, interpolationPe
|
||||||
}
|
}
|
||||||
|
|
||||||
var image = tileset.image.getSourceImage();
|
var image = tileset.image.getSourceImage();
|
||||||
|
|
||||||
var tileTexCoords = tileset.getTileTextureCoordinates(tile.index);
|
var tileTexCoords = tileset.getTileTextureCoordinates(tile.index);
|
||||||
|
|
||||||
if (tileTexCoords)
|
if (tileTexCoords)
|
||||||
{
|
{
|
||||||
var width = 0;
|
var width = tile.width;
|
||||||
var height = 0;
|
var height = tile.width;
|
||||||
|
|
||||||
if (src.layer.orientation === "isometric") {
|
if (src.layer.orientation === "isometric") {
|
||||||
// here we use the tileset width and height to fix problems with isometric map types
|
// here we use the tileset width and height to fix problems with isometric map types
|
||||||
width = tileset.tileWidth;
|
width = tileset.tileWidth;
|
||||||
width = tileset.tileHeight;
|
width = tileset.tileHeight;
|
||||||
} else {
|
|
||||||
width = tile.width;
|
|
||||||
height = tile.width
|
|
||||||
}
|
}
|
||||||
|
|
||||||
halfWidth = width / 2;
|
halfWidth = width / 2;
|
||||||
halfHeight = height / 2;
|
halfHeight = height / 2;
|
||||||
|
|
||||||
|
@ -185343,13 +185344,14 @@ var DynamicTilemapLayerCanvasRenderer = function (renderer, src, interpolationPe
|
||||||
ctx.drawImage(
|
ctx.drawImage(
|
||||||
image,
|
image,
|
||||||
tileTexCoords.x, tileTexCoords.y,
|
tileTexCoords.x, tileTexCoords.y,
|
||||||
width, height,
|
tileset.tileWidth, tileset.tileHeight,
|
||||||
-halfWidth, -halfHeight,
|
-halfWidth, -halfHeight,
|
||||||
width, height
|
width, height
|
||||||
);
|
);
|
||||||
|
|
||||||
ctx.restore();
|
ctx.restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.restore();
|
ctx.restore();
|
||||||
|
|
2
dist/phaser.min.js
vendored
2
dist/phaser.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -73,8 +73,6 @@ var ParseToTilemap = function (scene, key, tileWidth, tileHeight, width, height,
|
||||||
width: width,
|
width: width,
|
||||||
height: height
|
height: height
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
console.log(mapData.orientation)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Tilemap(scene, mapData);
|
return new Tilemap(scene, mapData);
|
||||||
|
|
|
@ -49,7 +49,6 @@ var Tile = new Class({
|
||||||
|
|
||||||
function Tile (layer, index, x, y, width, height, baseWidth, baseHeight )
|
function Tile (layer, index, x, y, width, height, baseWidth, baseHeight )
|
||||||
{
|
{
|
||||||
console.log(this)
|
|
||||||
/**
|
/**
|
||||||
* The LayerData in the Tilemap data that this tile belongs to.
|
* The LayerData in the Tilemap data that this tile belongs to.
|
||||||
*
|
*
|
||||||
|
@ -709,7 +708,7 @@ var Tile = new Class({
|
||||||
*/
|
*/
|
||||||
updatePixelXY: function ()
|
updatePixelXY: function ()
|
||||||
{
|
{
|
||||||
if (this.layer.orientation === "orthogonal") {
|
if (this.layer.orientation === "orthogonal") {
|
||||||
// In orthogonal mode, Tiled places tiles on a grid of baseWidth x baseHeight. The origin for a tile is the
|
// In orthogonal mode, 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.
|
||||||
|
@ -717,14 +716,14 @@ var Tile = new Class({
|
||||||
this.pixelY = this.y * this.baseHeight;
|
this.pixelY = this.y * this.baseHeight;
|
||||||
// console.log("orthopix "+this.pixelX+","+this.pixelY)
|
// console.log("orthopix "+this.pixelX+","+this.pixelY)
|
||||||
} else if (this.layer.orientation === "isometric" ) {
|
} else if (this.layer.orientation === "isometric" ) {
|
||||||
// for the image to be centered we have to move the image to the right with the camera !
|
// reminder : for the tilemap to be centered we have to move the image to the right with the camera !
|
||||||
// this is crucial for wordtotile, tiletoworld to work.
|
// this is crucial for wordtotile, tiletoworld to work.
|
||||||
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 "+this.pixelX+","+this.pixelY)
|
// console.log("isopix from",this.x, this.y,"to", this.pixelX+","+this.pixelY)
|
||||||
} else {
|
} else {
|
||||||
console.warn("this map orientation is not supported in this version of phaser")
|
// console.warn("this map orientation is not supported in this version of phaser")
|
||||||
console.log("tile orientation 3: "+this.layer.orientation)
|
// console.log("tile orientation 3: "+this.layer.orientation)
|
||||||
}
|
}
|
||||||
|
|
||||||
// this.pixelY = this.y * this.baseHeight - (this.height - this.baseHeight);
|
// this.pixelY = this.y * this.baseHeight - (this.height - this.baseHeight);
|
||||||
|
|
|
@ -27,16 +27,13 @@ var GetTileAt = function (tileX, tileY, nonNull, layer)
|
||||||
|
|
||||||
if (IsInLayerBounds(tileX, tileY, layer))
|
if (IsInLayerBounds(tileX, tileY, layer))
|
||||||
{
|
{
|
||||||
console.log("tile in bounds", tileX, tileY)
|
|
||||||
var tile = layer.data[tileY][tileX] || null;
|
var tile = layer.data[tileY][tileX] || null;
|
||||||
if (tile === null)
|
if (tile === null)
|
||||||
{
|
{
|
||||||
console.log("null tile", tileX, tileY)
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
else if (tile.index === -1)
|
else if (tile.index === -1)
|
||||||
{
|
{
|
||||||
console.log("null tile", tileX, tileY)
|
|
||||||
return nonNull ? tile : null;
|
return nonNull ? tile : null;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -37,9 +37,10 @@ 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, tile.width, tile.height);
|
layer.data[tileY][tileX] = new Tile(layer, tile.index, tileX, tileY, layer.tileWidth, layer.tileHeight);
|
||||||
}
|
}
|
||||||
layer.data[tileY][tileX].copy(tile);
|
layer.data[tileY][tileX].copy(tile);
|
||||||
}
|
}
|
||||||
|
@ -48,6 +49,7 @@ 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
|
||||||
|
@ -55,7 +57,6 @@ var PutTileAt = function (tile, tileX, tileY, recalculateFaces, layer)
|
||||||
layer.data[tileY][tileX].index = index;
|
layer.data[tileY][tileX].index = index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Updating colliding flag on the new tile
|
// Updating colliding flag on the new tile
|
||||||
var newTile = layer.data[tileY][tileX];
|
var newTile = layer.data[tileY][tileX];
|
||||||
var collides = layer.collideIndexes.indexOf(newTile.index) !== -1;
|
var collides = layer.collideIndexes.indexOf(newTile.index) !== -1;
|
||||||
|
|
|
@ -248,6 +248,9 @@ var DynamicTilemapLayer = new Class({
|
||||||
this.setSize(tilemap.tileWidth * this.layer.width, tilemap.tileHeight * this.layer.height);
|
this.setSize(tilemap.tileWidth * this.layer.width, tilemap.tileHeight * this.layer.height);
|
||||||
|
|
||||||
this.initPipeline('TextureTintPipeline');
|
this.initPipeline('TextureTintPipeline');
|
||||||
|
|
||||||
|
console.log("layer sizes")
|
||||||
|
console.log(this.layer.tileWidth,this.layer.tileHeight)
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -25,7 +25,6 @@ var DynamicTilemapLayerCanvasRenderer = function (renderer, src, interpolationPe
|
||||||
|
|
||||||
var renderTiles = src.culledTiles;
|
var renderTiles = src.culledTiles;
|
||||||
var tileCount = renderTiles.length;
|
var tileCount = renderTiles.length;
|
||||||
|
|
||||||
if (tileCount === 0)
|
if (tileCount === 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -75,8 +74,8 @@ var DynamicTilemapLayerCanvasRenderer = function (renderer, src, interpolationPe
|
||||||
|
|
||||||
for (var i = 0; i < tileCount; i++)
|
for (var i = 0; i < tileCount; i++)
|
||||||
{
|
{
|
||||||
var tile = renderTiles[i];
|
|
||||||
|
|
||||||
|
var tile = renderTiles[i];
|
||||||
var tileset = gidMap[tile.index];
|
var tileset = gidMap[tile.index];
|
||||||
|
|
||||||
if (!tileset)
|
if (!tileset)
|
||||||
|
@ -85,21 +84,20 @@ var DynamicTilemapLayerCanvasRenderer = function (renderer, src, interpolationPe
|
||||||
}
|
}
|
||||||
|
|
||||||
var image = tileset.image.getSourceImage();
|
var image = tileset.image.getSourceImage();
|
||||||
|
|
||||||
var tileTexCoords = tileset.getTileTextureCoordinates(tile.index);
|
var tileTexCoords = tileset.getTileTextureCoordinates(tile.index);
|
||||||
|
|
||||||
if (tileTexCoords)
|
if (tileTexCoords)
|
||||||
{
|
{
|
||||||
var width = 0;
|
var width = tile.width;
|
||||||
var height = 0;
|
var height = tile.width;
|
||||||
|
|
||||||
if (src.layer.orientation === "isometric") {
|
if (src.layer.orientation === "isometric") {
|
||||||
// here we use the tileset width and height to fix problems with isometric map types
|
// here we use the tileset width and height to fix problems with isometric map types
|
||||||
width = tileset.tileWidth;
|
width = tileset.tileWidth;
|
||||||
width = tileset.tileHeight;
|
width = tileset.tileHeight;
|
||||||
} else {
|
|
||||||
width = tile.width;
|
|
||||||
height = tile.width
|
|
||||||
}
|
}
|
||||||
|
|
||||||
halfWidth = width / 2;
|
halfWidth = width / 2;
|
||||||
halfHeight = height / 2;
|
halfHeight = height / 2;
|
||||||
|
|
||||||
|
@ -122,13 +120,14 @@ var DynamicTilemapLayerCanvasRenderer = function (renderer, src, interpolationPe
|
||||||
ctx.drawImage(
|
ctx.drawImage(
|
||||||
image,
|
image,
|
||||||
tileTexCoords.x, tileTexCoords.y,
|
tileTexCoords.x, tileTexCoords.y,
|
||||||
width, height,
|
tileset.tileWidth, tileset.tileHeight,
|
||||||
-halfWidth, -halfHeight,
|
-halfWidth, -halfHeight,
|
||||||
width, height
|
width, height
|
||||||
);
|
);
|
||||||
|
|
||||||
ctx.restore();
|
ctx.restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.restore();
|
ctx.restore();
|
||||||
|
|
Loading…
Reference in a new issue