Skip to content

Commit 2a4049d

Browse files
committed
Pass each Tile.alpha value and store it with the glBatch data.
NOTE: if implemented this will have to break the tile batch into separate batches based on the alpha values! Need a chat with Rich...
1 parent d43f29d commit 2a4049d

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

src/tilemap/TilemapLayerGL.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -704,11 +704,11 @@ Phaser.TilemapLayerGL.prototype.renderRegion = function (scrollX, scrollY, left,
704704

705705
var index = tile.index;
706706

707-
if (tile.alpha !== lastAlpha && !this.debug)
708-
{
709-
//context.globalAlpha = tile.alpha;
710-
lastAlpha = tile.alpha;
711-
}
707+
// if (tile.alpha !== lastAlpha && !this.debug)
708+
// {
709+
// //context.globalAlpha = tile.alpha;
710+
// lastAlpha = tile.alpha;
711+
// }
712712

713713
if (tile.rotation || tile.flipped)
714714
{
@@ -721,12 +721,12 @@ Phaser.TilemapLayerGL.prototype.renderRegion = function (scrollX, scrollY, left,
721721
// context.scale(-1, 1);
722722
// }
723723

724-
this._mc.tileset.drawGl(this.glBatch, -tile.centerX + offx, -tile.centerY + offy, index);
724+
this._mc.tileset.drawGl(this.glBatch, -tile.centerX + offx, -tile.centerY + offy, index, tile.alpha);
725725
//context.restore();
726726
}
727727
else
728728
{
729-
this._mc.tileset.drawGl(this.glBatch, tx + offx, ty + offy, index);
729+
this._mc.tileset.drawGl(this.glBatch, tx + offx, ty + offy, index, tile.alpha);
730730
}
731731
// if (!this._mc.tileset && this.debugSettings.missingImageFill)
732732
// {
@@ -768,7 +768,7 @@ Phaser.TilemapLayerGL.prototype.renderFull = function () {
768768

769769
var left = Math.floor( (scrollX - (cw - tw)) / tw );
770770
var right = Math.floor( (renderW - 1 + scrollX) / tw );
771-
var top = Math.floor( scrollY - (ch - th) / th );
771+
var top = Math.floor( (scrollY - (ch - th)) / th );
772772
var bottom = Math.floor( (renderH - 1 + scrollY) / th );
773773

774774
this.glBatch = [];

src/tilemap/Tileset.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,9 @@ Phaser.Tileset.prototype = {
162162
* @param {number} x - The x coordinate to draw to.
163163
* @param {number} y - The y coordinate to draw to.
164164
* @param {integer} index - The index of the tile within the set to draw.
165+
* @param {number} alpha - The alpha value to draw this tile with.
165166
*/
166-
drawGl: function (glBatch, x, y, index) {
167+
drawGl: function (glBatch, x, y, index, alpha) {
167168

168169
// Correct the tile index for the set and bias for interlacing x/y values
169170
var coordIndex = (index - this.firstgid) * 2;
@@ -181,7 +182,8 @@ Phaser.Tileset.prototype = {
181182
dx: x + this.tileWidth * 0.5,
182183
dy: y + this.tileHeight * 0.5,
183184
dw: this.tileWidth,
184-
dh: this.tileHeight
185+
dh: this.tileHeight,
186+
alpha: alpha
185187
} );
186188
}
187189

0 commit comments

Comments
 (0)