Camera effect rendering for canvas

This commit is contained in:
Felipe Alfonso 2017-02-21 17:15:44 -03:00
parent d309be3b2e
commit 365b9ec3f4
2 changed files with 18 additions and 3 deletions

View file

@ -1,4 +1,4 @@
var CHECKSUM = {
build: '692fe170-f870-11e6-8132-938c0b25d0cb'
build: '6393ce50-f872-11e6-ba94-79064404f409'
};
module.exports = CHECKSUM;

View file

@ -215,14 +215,29 @@ CanvasRenderer.prototype = {
// Call the State.render function
state.render.call(state, ctx, interpolationPercentage);
ctx.setTransform(1, 0, 0, 1, 0, 0);
if (camera._fadeAlpha > 0 || camera._flashAlpha > 0)
{
// fade rendering
ctx.fillStyle = 'rgb(' + (camera._fadeRed * 255) + ',' + (camera._fadeGreen * 255) + ',' + (camera._fadeBlue * 255) + ')';
ctx.globalAlpha = camera._fadeAlpha;
ctx.fillRect(camera.x, camera.y, camera.width, camera.height);
// flash rendering
ctx.fillStyle = 'rgb(' + (camera._flashRed * 255) + ',' + (camera._flashGreen * 255) + ',' + (camera._flashBlue * 255) + ')';
ctx.globalAlpha = camera._flashAlpha;
ctx.fillRect(camera.x, camera.y, camera.width, camera.height);
ctx.globalAlpha = 1.0;
}
// Reset the camera scissor
if (scissor)
{
ctx.restore();
}
ctx.setTransform(1, 0, 0, 1, 0, 0);
// Blast it to the Game Canvas (if needed)
if (settings.renderToTexture)
{