Use proper matrix for static layer, so we can do fun things with Render Textures

This commit is contained in:
Richard Davey 2018-08-02 22:15:08 +01:00
parent 8135b687fb
commit 318cc87e59

View file

@ -28,14 +28,25 @@ var StaticTilemapLayerCanvasRenderer = function (renderer, src, interpolationPer
var tileCount = renderTiles.length; var tileCount = renderTiles.length;
var image = tileset.image.getSourceImage(); var image = tileset.image.getSourceImage();
var tx = src.x - camera.scrollX * src.scrollFactorX;
var ty = src.y - camera.scrollY * src.scrollFactorY; var camMatrix = renderer._tempMatrix1;
var layerMatrix = renderer._tempMatrix2;
var calcMatrix = renderer._tempMatrix3;
layerMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY);
ctx.save(); ctx.save();
ctx.translate(tx, ty);
ctx.rotate(src.rotation); camMatrix.copyFrom(camera.matrix);
ctx.scale(src.scaleX, src.scaleY);
ctx.scale(src.flipX ? -1 : 1, src.flipY ? -1 : 1); layerMatrix.e -= camera.scrollX * src.scrollFactorX;
layerMatrix.f -= camera.scrollY * src.scrollFactorY;
// Multiply by the Sprite matrix, store result in calcMatrix
camMatrix.multiply(layerMatrix, calcMatrix);
calcMatrix.copyToContext(ctx);
ctx.globalAlpha = camera.alpha * src.alpha; ctx.globalAlpha = camera.alpha * src.alpha;
for (var index = 0; index < tileCount; ++index) for (var index = 0; index < tileCount; ++index)