mirror of
https://github.com/photonstorm/phaser
synced 2024-11-27 15:12:18 +00:00
Cameras draw their backgrounds correctly at higher resolutions
This commit is contained in:
parent
e29671282b
commit
1c473afa84
2 changed files with 8 additions and 3 deletions
|
@ -385,6 +385,11 @@ var CanvasRenderer = new Class({
|
|||
var list = children.list;
|
||||
var resolution = this.config.resolution;
|
||||
|
||||
var cx = Math.floor(camera.x * resolution);
|
||||
var cy = Math.floor(camera.y * resolution);
|
||||
var cw = Math.floor(camera.width * resolution);
|
||||
var ch = Math.floor(camera.height * resolution);
|
||||
|
||||
this.currentContext = ctx;
|
||||
|
||||
// If the alpha or blend mode didn't change since the last render, then don't set them again (saves 2 ops)
|
||||
|
@ -392,7 +397,7 @@ var CanvasRenderer = new Class({
|
|||
if (!camera.transparent)
|
||||
{
|
||||
ctx.fillStyle = camera.backgroundColor.rgba;
|
||||
ctx.fillRect(camera.x, camera.y, camera.width, camera.height);
|
||||
ctx.fillRect(cx, cy, cw, ch);
|
||||
}
|
||||
|
||||
ctx.globalAlpha = camera.alpha;
|
||||
|
@ -413,7 +418,7 @@ var CanvasRenderer = new Class({
|
|||
{
|
||||
ctx.save();
|
||||
ctx.beginPath();
|
||||
ctx.rect(camera.x * resolution, camera.y * resolution, camera.width * resolution, camera.height * resolution);
|
||||
ctx.rect(cx, cy, cw, ch);
|
||||
ctx.clip();
|
||||
}
|
||||
|
||||
|
|
|
@ -1484,7 +1484,7 @@ var WebGLRenderer = new Class({
|
|||
|
||||
FlatTintPipeline.batchFillRect(
|
||||
0, 0, 1, 1, 0,
|
||||
camera.x, camera.y, camera.width, camera.height,
|
||||
cx, cy, cw, ch,
|
||||
Utils.getTintFromFloats(color.redGL, color.greenGL, color.blueGL, 1.0),
|
||||
color.alphaGL,
|
||||
1, 0, 0, 1, 0, 0,
|
||||
|
|
Loading…
Reference in a new issue