Skip to content

Instantly share code, notes, and snippets.

@Paratron
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Paratron/11198778 to your computer and use it in GitHub Desktop.
Save Paratron/11198778 to your computer and use it in GitHub Desktop.
Iso fix
/**
* Renders the tiles to the layer canvas and pushes to the display.
* @method Phaser.TilemapLayer#render
* @memberof Phaser.TilemapLayer
*/
Phaser.TilemapLayer.prototype.render = function () {
if (this.layer.dirty)
{
this.dirty = true;
}
if (!this.dirty || !this.visible)
{
return;
}
this._mc.prevX = this._mc.dx;
this._mc.prevY = this._mc.dy;
this._mc.dx = this._mc.x + ((this.map.width * this.map.tileWidth) / 2);
this._mc.dy = -(this._mc.y);
this._mc.tx = this._mc.dx;
this._mc.ty = this._mc.dy;
this.context.clearRect(0, 0, this.canvas.width, this.canvas.height);
this.context.fillStyle = this.tileColor;
var tile;
var set;
if (this.debug)
{
this.context.globalAlpha = this.debugAlpha;
}
this._mc.dy = this._mc.ty;
for (var y = this._mc.startY, lenY = this._mc.startY + this._mc.maxY; y < lenY; y++)
{
this._column = this.layer.data[y];
this._mc.dx = this._mc.tx;
for (var x = this._mc.startX, lenX = this._mc.startX + this._mc.maxX; x < lenX; x++)
{
if (this._column[x])
{
tile = this._column[x];
set = this.map.tilesets[this.map.tiles[tile.index][2]];
if (this.debug === false && tile.alpha !== this.context.globalAlpha)
{
this.context.globalAlpha = tile.alpha;
}
set.draw(this.context, Math.floor(this._mc.tx), Math.floor(this._mc.ty), tile.index);
if(x > 5){
//return;
}
if (tile.debug)
{
this.context.fillStyle = 'rgba(0, 255, 0, 0.4)';
this.context.fillRect(Math.floor(this._mc.tx), Math.floor(this._mc.ty), this.map.tileWidth, this.map.tileHeight);
}
}
this._mc.tx += this.map.tileWidth / 2;
this._mc.ty += this.map.tileHeight / 2;
}
this._mc.tx = this._mc.dx - this.map.tileWidth / 2;
this._mc.ty = this._mc.dy + this.map.tileHeight / 2 + (y * (this.map.tileHeight / 2));
}
if (this.debug)
{
this.context.globalAlpha = 1;
this.renderDebug();
}
if (this.game.renderType === Phaser.WEBGL)
{
// PIXI.updateWebGLTexture(this.baseTexture, renderSession.gl);
PIXI.updateWebGLTexture(this.baseTexture, this.game.renderer.gl);
}
this.dirty = false;
this.layer.dirty = false;
return true;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment