mirror of
https://github.com/photonstorm/phaser
synced 2024-11-27 07:01:20 +00:00
Fixed layer size calculations. Also changed rendering to use tileset tile sizes, as it should do.
This commit is contained in:
parent
74d5af20c6
commit
eef553d4c2
3 changed files with 19 additions and 17 deletions
|
@ -247,7 +247,7 @@ var DynamicTilemapLayer = new Class({
|
|||
this.setAlpha(this.layer.alpha);
|
||||
this.setPosition(x, y);
|
||||
this.setOrigin();
|
||||
this.setSize(this.layer.tileWidth * this.layer.width, this.layer.tileHeight * this.layer.height);
|
||||
this.setSize(tileset.tileWidth * this.layer.width, tileset.tileHeight * this.layer.height);
|
||||
|
||||
this.initPipeline('TextureTintPipeline');
|
||||
},
|
||||
|
|
|
@ -355,7 +355,7 @@ var StaticTilemapLayer = new Class({
|
|||
this.setAlpha(this.layer.alpha);
|
||||
this.setPosition(x, y);
|
||||
this.setOrigin();
|
||||
this.setSize(this.layer.tileWidth * this.layer.width, this.layer.tileHeight * this.layer.height);
|
||||
this.setSize(tileset.tileWidth * this.layer.width, tileset.tileHeight * this.layer.height);
|
||||
|
||||
this.updateVBOData();
|
||||
|
||||
|
@ -596,8 +596,8 @@ var StaticTilemapLayer = new Class({
|
|||
* @param {integer} vOffset - The vertex offset.
|
||||
* @param {any} tile - The tile being rendered.
|
||||
* @param {any} tileset - The tileset being used for rendering.
|
||||
* @param {integer} width - The width of the layer.
|
||||
* @param {integer} height - The height of the layer.
|
||||
* @param {integer} width - The width of the tileset image in pixels.
|
||||
* @param {integer} height - The height of the tileset image in pixels.
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - The camera the layer is being rendered with.
|
||||
* @param {integer} tilesetIndex - The tileset index.
|
||||
*
|
||||
|
@ -612,19 +612,19 @@ var StaticTilemapLayer = new Class({
|
|||
return vOffset;
|
||||
}
|
||||
|
||||
var u0 = texCoords.x / width;
|
||||
var v0 = texCoords.y / height;
|
||||
var u1 = (texCoords.x + tile.width) / width;
|
||||
var v1 = (texCoords.y + tile.height) / height;
|
||||
|
||||
var matrix = this._tempMatrix;
|
||||
|
||||
var tileWidth = tile.width;
|
||||
var tileHeight = tile.height;
|
||||
var tileWidth = tileset.tileWidth;
|
||||
var tileHeight = tileset.tileHeight;
|
||||
|
||||
var halfTileWidth = tileWidth / 2;
|
||||
var halfTileHeight = tileHeight / 2;
|
||||
|
||||
var u0 = texCoords.x / width;
|
||||
var v0 = texCoords.y / height;
|
||||
var u1 = (texCoords.x + tileWidth) / width;
|
||||
var v1 = (texCoords.y + tileHeight) / height;
|
||||
|
||||
var matrix = this._tempMatrix;
|
||||
|
||||
var x = -halfTileWidth;
|
||||
var y = -halfTileHeight;
|
||||
|
||||
|
|
|
@ -86,8 +86,10 @@ var StaticTilemapLayerCanvasRenderer = function (renderer, src, interpolationPer
|
|||
|
||||
if (tileTexCoords)
|
||||
{
|
||||
var halfWidth = tile.width / 2;
|
||||
var halfHeight = tile.height / 2;
|
||||
var tileWidth = tileset.tileWidth;
|
||||
var tileHeight = tileset.tileHeight;
|
||||
var halfWidth = tileWidth / 2;
|
||||
var halfHeight = tileHeight / 2;
|
||||
|
||||
ctx.save();
|
||||
|
||||
|
@ -108,9 +110,9 @@ var StaticTilemapLayerCanvasRenderer = function (renderer, src, interpolationPer
|
|||
ctx.drawImage(
|
||||
image,
|
||||
tileTexCoords.x, tileTexCoords.y,
|
||||
tile.width, tile.height,
|
||||
tileWidth, tileHeight,
|
||||
-halfWidth, -halfHeight,
|
||||
tile.width, tile.height
|
||||
tileWidth, tileHeight
|
||||
);
|
||||
|
||||
ctx.restore();
|
||||
|
|
Loading…
Reference in a new issue