mirror of
https://github.com/photonstorm/phaser
synced 2024-11-24 05:33:35 +00:00
BaseCamera.renderRoundPixels
is a new read-only property that is set during the Camera preRender
method every frame. It is true if the Camera is set to render round pixels and the zoom values are integers, otherwise it is false. This is then fed into the MultiPipeline when rendering sprites and textures.
This commit is contained in:
parent
13177a4e4a
commit
8e432aee8d
2 changed files with 20 additions and 1 deletions
|
@ -517,6 +517,22 @@ var BaseCamera = new Class({
|
|||
* @since 3.60.0
|
||||
*/
|
||||
this.isSceneCamera = true;
|
||||
|
||||
/**
|
||||
* Can this Camera render rounded pixel values?
|
||||
*
|
||||
* This property is updated during the `preRender` method and should not be
|
||||
* set directly. It is set based on the `roundPixels` property of the Camera
|
||||
* combined with the zoom level. If the zoom is an integer then the WebGL
|
||||
* Renderer can apply rounding during rendering.
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.BaseCamera#renderRoundPixels
|
||||
* @type {boolean}
|
||||
* @readonly
|
||||
* @default true
|
||||
* @since 3.86.0
|
||||
*/
|
||||
this.renderRoundPixels = true;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -501,6 +501,8 @@ var Camera = new Class({
|
|||
var zoomY = this.zoomY;
|
||||
var matrix = this.matrix;
|
||||
|
||||
this.renderRoundPixels = (this.roundPixels && Number.isInteger(zoomX) && Number.isInteger(zoomY));
|
||||
|
||||
var originX = width * this.originX;
|
||||
var originY = height * this.originY;
|
||||
|
||||
|
@ -589,7 +591,8 @@ var Camera = new Class({
|
|||
Math.floor(this.x + originX + 0.5),
|
||||
Math.floor(this.y + originY + 0.5),
|
||||
this.rotation,
|
||||
zoomX, zoomY);
|
||||
zoomX, zoomY
|
||||
);
|
||||
|
||||
matrix.translate(-originX, -originY);
|
||||
|
||||
|
|
Loading…
Reference in a new issue