Skip to content

Commit d1f2c92

Browse files
committed
Resolution removal
* The `BaseCamera.resolution` property has been removed. * The internal private `BaseCamera._cx`, `_cy`, `_cw` and `_ch` properties has been removed. * The `BaseCamera.preRender` method no longer receives or uses the `resolution` parameter.
1 parent 3eece86 commit d1f2c92

1 file changed

Lines changed: 22 additions & 94 deletions

File tree

src/cameras/2d/BaseCamera.js

Lines changed: 22 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ var Vector2 = require('../../math/Vector2');
3434
*
3535
* By default a Camera will render all Game Objects it can see. You can change this using the `ignore` method,
3636
* allowing you to filter Game Objects out on a per-Camera basis.
37-
*
37+
*
3838
* The Base Camera is extended by the Camera class, which adds in special effects including Fade,
3939
* Flash and Camera Shake, as well as the ability to follow Game Objects.
40-
*
40+
*
4141
* The Base Camera was introduced in Phaser 3.12. It was split off from the Camera class, to allow
4242
* you to isolate special effects as needed. Therefore the 'since' values for properties of this class relate
4343
* to when they were added to the Camera class.
@@ -46,7 +46,7 @@ var Vector2 = require('../../math/Vector2');
4646
* @memberof Phaser.Cameras.Scene2D
4747
* @constructor
4848
* @since 3.12.0
49-
*
49+
*
5050
* @extends Phaser.Events.EventEmitter
5151
* @extends Phaser.GameObjects.Components.Alpha
5252
* @extends Phaser.GameObjects.Components.Visible
@@ -133,19 +133,6 @@ var BaseCamera = new Class({
133133
*/
134134
this.name = '';
135135

136-
/**
137-
* This property is un-used in v3.16.
138-
*
139-
* The resolution of the Game, used in most Camera calculations.
140-
*
141-
* @name Phaser.Cameras.Scene2D.BaseCamera#resolution
142-
* @type {number}
143-
* @readonly
144-
* @deprecated
145-
* @since 3.12.0
146-
*/
147-
this.resolution = 1;
148-
149136
/**
150137
* Should this camera round its pixel values to integers?
151138
*
@@ -195,9 +182,9 @@ var BaseCamera = new Class({
195182

196183
/**
197184
* Is this Camera dirty?
198-
*
185+
*
199186
* A dirty Camera has had either its viewport size, bounds, scroll, rotation or zoom levels changed since the last frame.
200-
*
187+
*
201188
* This flag is cleared during the `postRenderCamera` method of the renderer.
202189
*
203190
* @name Phaser.Cameras.Scene2D.BaseCamera#dirty
@@ -231,46 +218,6 @@ var BaseCamera = new Class({
231218
*/
232219
this._y = y;
233220

234-
/**
235-
* Internal Camera X value multiplied by the resolution.
236-
*
237-
* @name Phaser.Cameras.Scene2D.BaseCamera#_cx
238-
* @type {number}
239-
* @private
240-
* @since 3.12.0
241-
*/
242-
this._cx = 0;
243-
244-
/**
245-
* Internal Camera Y value multiplied by the resolution.
246-
*
247-
* @name Phaser.Cameras.Scene2D.BaseCamera#_cy
248-
* @type {number}
249-
* @private
250-
* @since 3.12.0
251-
*/
252-
this._cy = 0;
253-
254-
/**
255-
* Internal Camera Width value multiplied by the resolution.
256-
*
257-
* @name Phaser.Cameras.Scene2D.BaseCamera#_cw
258-
* @type {number}
259-
* @private
260-
* @since 3.12.0
261-
*/
262-
this._cw = 0;
263-
264-
/**
265-
* Internal Camera Height value multiplied by the resolution.
266-
*
267-
* @name Phaser.Cameras.Scene2D.BaseCamera#_ch
268-
* @type {number}
269-
* @private
270-
* @since 3.12.0
271-
*/
272-
this._ch = 0;
273-
274221
/**
275222
* The width of the Camera viewport, in pixels.
276223
*
@@ -513,7 +460,7 @@ var BaseCamera = new Class({
513460

514461
/**
515462
* The Camera that this Camera uses for translation during masking.
516-
*
463+
*
517464
* If the mask is fixed in position this will be a reference to
518465
* the CameraManager.default instance. Otherwise, it'll be a reference
519466
* to itself.
@@ -847,18 +794,16 @@ var BaseCamera = new Class({
847794
var s = Math.sin(this.rotation);
848795

849796
var zoom = this.zoom;
850-
var res = this.resolution;
851797

852798
var scrollX = this.scrollX;
853799
var scrollY = this.scrollY;
854800

855-
// Works for zoom of 1 with any resolution, but resolution > 1 and zoom !== 1 breaks
856801
var sx = x + ((scrollX * c - scrollY * s) * zoom);
857802
var sy = y + ((scrollX * s + scrollY * c) * zoom);
858803

859804
// Apply transform to point
860-
output.x = (sx * ima + sy * imc) * res + ime;
861-
output.y = (sx * imb + sy * imd) * res + imf;
805+
output.x = (sx * ima + sy * imc) + ime;
806+
output.y = (sx * imb + sy * imd) + imf;
862807

863808
return output;
864809
},
@@ -910,18 +855,16 @@ var BaseCamera = new Class({
910855
* @method Phaser.Cameras.Scene2D.BaseCamera#preRender
911856
* @protected
912857
* @since 3.0.0
913-
*
914-
* @param {number} resolution - The game resolution, as set in the Scale Manager.
915858
*/
916-
preRender: function (resolution)
859+
preRender: function ()
917860
{
918861
var width = this.width;
919862
var height = this.height;
920863

921864
var halfWidth = width * 0.5;
922865
var halfHeight = height * 0.5;
923866

924-
var zoom = this.zoom * resolution;
867+
var zoom = this.zoom;
925868
var matrix = this.matrix;
926869

927870
var originX = width * this.originX;
@@ -1104,15 +1047,15 @@ var BaseCamera = new Class({
11041047

11051048
/**
11061049
* Set the bounds of the Camera. The bounds are an axis-aligned rectangle.
1107-
*
1050+
*
11081051
* The Camera bounds controls where the Camera can scroll to, stopping it from scrolling off the
11091052
* edges and into blank space. It does not limit the placement of Game Objects, or where
11101053
* the Camera viewport can be positioned.
1111-
*
1054+
*
11121055
* Temporarily disable the bounds by changing the boolean `Camera.useBounds`.
1113-
*
1056+
*
11141057
* Clear the bounds entirely by calling `Camera.removeBounds`.
1115-
*
1058+
*
11161059
* If you set bounds that are smaller than the viewport it will stop the Camera from being
11171060
* able to scroll. The bounds can be positioned where-ever you wish. By default they are from
11181061
* 0x0 to the canvas width x height. This means that the coordinate 0x0 is the top left of
@@ -1156,9 +1099,9 @@ var BaseCamera = new Class({
11561099

11571100
/**
11581101
* Returns a rectangle containing the bounds of the Camera.
1159-
*
1102+
*
11601103
* If the Camera does not have any bounds the rectangle will be empty.
1161-
*
1104+
*
11621105
* The rectangle is a copy of the bounds, so is safe to modify.
11631106
*
11641107
* @method Phaser.Cameras.Scene2D.BaseCamera#getBounds
@@ -1245,7 +1188,7 @@ var BaseCamera = new Class({
12451188

12461189
/**
12471190
* Should the Camera round pixel values to whole integers when rendering Game Objects?
1248-
*
1191+
*
12491192
* In some types of game, especially with pixel art, this is required to prevent sub-pixel aliasing.
12501193
*
12511194
* @method Phaser.Cameras.Scene2D.BaseCamera#setRoundPixels
@@ -1264,8 +1207,6 @@ var BaseCamera = new Class({
12641207

12651208
/**
12661209
* Sets the Scene the Camera is bound to.
1267-
*
1268-
* Also populates the `resolution` property and updates the internal size values.
12691210
*
12701211
* @method Phaser.Cameras.Scene2D.BaseCamera#setScene
12711212
* @since 3.0.0
@@ -1289,15 +1230,6 @@ var BaseCamera = new Class({
12891230
this.scaleManager = sys.scale;
12901231
this.cameraManager = sys.cameras;
12911232

1292-
var res = this.scaleManager.resolution;
1293-
1294-
this.resolution = res;
1295-
1296-
this._cx = this._x * res;
1297-
this._cy = this._y * res;
1298-
this._cw = this._width * res;
1299-
this._ch = this._height * res;
1300-
13011233
this.updateSystem();
13021234

13031235
return this;
@@ -1419,14 +1351,14 @@ var BaseCamera = new Class({
14191351
* Sets the mask to be applied to this Camera during rendering.
14201352
*
14211353
* The mask must have been previously created and can be either a GeometryMask or a BitmapMask.
1422-
*
1354+
*
14231355
* Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas.
14241356
*
14251357
* If a mask is already set on this Camera it will be immediately replaced.
1426-
*
1358+
*
14271359
* Masks have no impact on physics or input detection. They are purely a rendering component
14281360
* that allows you to limit what is visible during the render pass.
1429-
*
1361+
*
14301362
* Note: You cannot mask a Camera that has `renderToTexture` set.
14311363
*
14321364
* @method Phaser.Cameras.Scene2D.BaseCamera#setMask
@@ -1573,9 +1505,9 @@ var BaseCamera = new Class({
15731505
/**
15741506
* Destroys this Camera instance and its internal properties and references.
15751507
* Once destroyed you cannot use this Camera again, even if re-added to a Camera Manager.
1576-
*
1508+
*
15771509
* This method is called automatically by `CameraManager.remove` if that methods `runDestroy` argument is `true`, which is the default.
1578-
*
1510+
*
15791511
* Unless you have a specific reason otherwise, always use `CameraManager.remove` and allow it to handle the camera destruction,
15801512
* rather than calling this method directly.
15811513
*
@@ -1626,7 +1558,6 @@ var BaseCamera = new Class({
16261558
set: function (value)
16271559
{
16281560
this._x = value;
1629-
this._cx = value * this.resolution;
16301561
this.updateSystem();
16311562
}
16321563

@@ -1651,7 +1582,6 @@ var BaseCamera = new Class({
16511582
set: function (value)
16521583
{
16531584
this._y = value;
1654-
this._cy = value * this.resolution;
16551585
this.updateSystem();
16561586
}
16571587

@@ -1677,7 +1607,6 @@ var BaseCamera = new Class({
16771607
set: function (value)
16781608
{
16791609
this._width = value;
1680-
this._cw = value * this.resolution;
16811610
this.updateSystem();
16821611
}
16831612

@@ -1703,7 +1632,6 @@ var BaseCamera = new Class({
17031632
set: function (value)
17041633
{
17051634
this._height = value;
1706-
this._ch = value * this.resolution;
17071635
this.updateSystem();
17081636
}
17091637

0 commit comments

Comments
 (0)