diff --git a/src/extras/TilingSprite.js b/src/extras/TilingSprite.js index f90d248..fe82451 100644 --- a/src/extras/TilingSprite.js +++ b/src/extras/TilingSprite.js @@ -220,20 +220,33 @@ transform.tx * resolution, transform.ty * resolution); - // TODO - this should be rolled into the setTransform above.. - context.scale(this.tileScale.x / baseTextureResolution, this.tileScale.y / baseTextureResolution); - - context.translate(modX + (this.anchor.x * -this._width), - modY + (this.anchor.y * -this._height)); - renderer.setBlendMode(this.blendMode); // fill the pattern! context.fillStyle = this._canvasPattern; - context.fillRect(-modX, - -modY, - this._width / this.tileScale.x * baseTextureResolution, - this._height / this.tileScale.y * baseTextureResolution); + + // TODO - this should be rolled into the setTransform above.. + context.scale(this.tileScale.x / baseTextureResolution, this.tileScale.y / baseTextureResolution); + + const anchorX = this.anchor.x * -this._width; + const anchorY = this.anchor.y * -this._height; + + if (this.uvRespectAnchor) + { + context.translate(modX, modY); + + context.fillRect(-modX + anchorX, -modY + anchorY, + this._width / this.tileScale.x * baseTextureResolution, + this._height / this.tileScale.y * baseTextureResolution); + } + else + { + context.translate(modX + anchorX, modY + anchorY); + + context.fillRect(-modX, -modY, + this._width / this.tileScale.x * baseTextureResolution, + this._height / this.tileScale.y * baseTextureResolution); + } } /**