mirror of
https://github.com/photonstorm/phaser
synced 2024-11-23 21:24:09 +00:00
Use proper matrix for static layer, so we can do fun things with Render Textures
This commit is contained in:
parent
8135b687fb
commit
318cc87e59
1 changed files with 17 additions and 6 deletions
|
@ -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)
|
||||||
|
|
Loading…
Reference in a new issue