Skip to content

Commit 858c858

Browse files
committed
Merge branch 'master' of https://github.com/photonstorm/phaser
2 parents 016c572 + e22b1a7 commit 858c858

117 files changed

Lines changed: 1261 additions & 938 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 63 additions & 9 deletions
Large diffs are not rendered by default.

src/animations/Animation.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ var GetValue = require('../utils/object/GetValue');
3232
*
3333
* @property {string} key - The key that the animation will be associated with. i.e. sprite.animations.play(key)
3434
* @property {(string|number)} frame - [description]
35-
* @property {float} [duration=0] - [description]
35+
* @property {number} [duration=0] - [description]
3636
* @property {boolean} [visible] - [description]
3737
*/
3838

@@ -545,7 +545,7 @@ var Animation = new Class({
545545
* @method Phaser.Animations.Animation#getFrameByProgress
546546
* @since 3.4.0
547547
*
548-
* @param {float} value - A value between 0 and 1.
548+
* @param {number} value - A value between 0 and 1.
549549
*
550550
* @return {Phaser.Animations.AnimationFrame} The frame closest to the given progress value.
551551
*/

src/boot/Config.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -324,24 +324,30 @@ var Config = new Class({
324324
var renderConfig = GetValue(config, 'render', config);
325325

326326
/**
327-
* @const {boolean} Phaser.Boot.Config#antialias - [description]
327+
* @const {boolean} Phaser.Boot.Config#autoResize - [description]
328328
*/
329-
this.antialias = GetValue(renderConfig, 'antialias', true);
329+
this.autoResize = GetValue(renderConfig, 'autoResize', false);
330330

331331
/**
332-
* @const {boolean} Phaser.Boot.Config#pixelArt - [description]
332+
* @const {boolean} Phaser.Boot.Config#antialias - [description]
333333
*/
334-
this.pixelArt = GetValue(renderConfig, 'pixelArt', false);
334+
this.antialias = GetValue(renderConfig, 'antialias', true);
335335

336336
/**
337-
* @const {boolean} Phaser.Boot.Config#autoResize - [description]
337+
* @const {boolean} Phaser.Boot.Config#roundPixels - [description]
338338
*/
339-
this.autoResize = GetValue(renderConfig, 'autoResize', false);
339+
this.roundPixels = GetValue(renderConfig, 'roundPixels', false);
340340

341341
/**
342-
* @const {boolean} Phaser.Boot.Config#roundPixels - [description]
342+
* @const {boolean} Phaser.Boot.Config#pixelArt - [description]
343343
*/
344-
this.roundPixels = GetValue(renderConfig, 'roundPixels', false);
344+
this.pixelArt = GetValue(renderConfig, 'pixelArt', false);
345+
346+
if (this.pixelArt)
347+
{
348+
this.antialias = false;
349+
this.roundPixels = true;
350+
}
345351

346352
/**
347353
* @const {boolean} Phaser.Boot.Config#transparent - [description]

src/boot/CreateRenderer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ var CreateRenderer = function (game)
4848
}
4949

5050
// Pixel Art mode?
51-
if (config.pixelArt)
51+
if (!config.antialias)
5252
{
5353
CanvasPool.disableSmoothing();
5454
}
@@ -70,7 +70,7 @@ var CreateRenderer = function (game)
7070
}
7171

7272
// Pixel Art mode?
73-
if (config.pixelArt)
73+
if (!config.antialias)
7474
{
7575
CanvasInterpolation.setCrisp(game.canvas);
7676
}

src/cameras/2d/Camera.js

Lines changed: 81 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,17 @@ var Camera = new Class({
9494
*/
9595
this.scene;
9696

97+
/**
98+
* The Camera ID. Assigned by the Camera Manager and used to handle camera exclusion.
99+
* This value is a bitmask.
100+
*
101+
* @name Phaser.Cameras.Scene2D.Camera#id
102+
* @type {integer}
103+
* @readOnly
104+
* @since 3.11.0
105+
*/
106+
this.id = 0;
107+
97108
/**
98109
* The name of the Camera. This is left empty for your own use.
99110
*
@@ -251,7 +262,7 @@ var Camera = new Class({
251262
* Be careful to never set this value to zero.
252263
*
253264
* @name Phaser.Cameras.Scene2D.Camera#zoom
254-
* @type {float}
265+
* @type {number}
255266
* @default 1
256267
* @since 3.0.0
257268
*/
@@ -302,6 +313,18 @@ var Camera = new Class({
302313
*/
303314
this.backgroundColor = ValueToColor('rgba(0,0,0,0)');
304315

316+
/**
317+
* The Camera alpha value. Setting this property impacts every single object that this Camera
318+
* renders. You can either set the property directly, i.e. via a Tween, to fade a Camera in or out,
319+
* or via the chainable `setAlpha` method instead.
320+
*
321+
* @name Phaser.Cameras.Scene2D.Camera#alpha
322+
* @type {number}
323+
* @default 1
324+
* @since 3.11.0
325+
*/
326+
this.alpha = 1;
327+
305328
/**
306329
* The Camera Fade effect handler.
307330
* To fade this camera see the `Camera.fade` methods.
@@ -429,7 +452,7 @@ var Camera = new Class({
429452
* See `setOrigin` to set both origins in a single, chainable call.
430453
*
431454
* @name Phaser.Cameras.Scene2D.Camera#originX
432-
* @type {float}
455+
* @type {number}
433456
* @default 0.5
434457
* @since 3.11.0
435458
*/
@@ -446,7 +469,7 @@ var Camera = new Class({
446469
* See `setOrigin` to set both origins in a single, chainable call.
447470
*
448471
* @name Phaser.Cameras.Scene2D.Camera#originY
449-
* @type {float}
472+
* @type {number}
450473
* @default 0.5
451474
* @since 3.11.0
452475
*/
@@ -487,17 +510,26 @@ var Camera = new Class({
487510
* @since 3.0.0
488511
*/
489512
this._follow = null;
513+
},
490514

491-
/**
492-
* Internal camera ID. Assigned by the Camera Manager and used in the camera pool.
493-
*
494-
* @name Phaser.Cameras.Scene2D.Camera#_id
495-
* @type {integer}
496-
* @private
497-
* @default 0
498-
* @since 3.0.0
499-
*/
500-
this._id = 0;
515+
/**
516+
* Set the Alpha level of this Camera. The alpha controls the opacity of the Camera as it renders.
517+
* Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque.
518+
*
519+
* @method Phaser.GameObjects.Components.Origin#setAlpha
520+
* @since 3.11.0
521+
*
522+
* @param {number} [value=1] - The Camera alpha value.
523+
*
524+
* @return {this} This Camera instance.
525+
*/
526+
setAlpha: function (value)
527+
{
528+
if (value === undefined) { value = 1; }
529+
530+
this.alpha = value;
531+
532+
return this;
501533
},
502534

503535
/**
@@ -1029,7 +1061,7 @@ var Camera = new Class({
10291061
*/
10301062
ignore: function (gameObject)
10311063
{
1032-
var id = this._id;
1064+
var id = this.id;
10331065

10341066
if (Array.isArray(gameObject))
10351067
{
@@ -1317,10 +1349,23 @@ var Camera = new Class({
13171349
},
13181350

13191351
/**
1320-
* Set the world bounds for this Camera.
1321-
*
1322-
* A Camera bounds controls where the camera can scroll to within the world. It does not limit
1323-
* rendering of the camera, or placement of the viewport within your game.
1352+
* Set the bounds of the Camera. The bounds are an axis-aligned rectangle.
1353+
*
1354+
* The Camera bounds controls where the Camera can scroll to, stopping it from scrolling off the
1355+
* edges and into blank space. It does not limit the placement of Game Objects, or where
1356+
* the Camera viewport can be positioned.
1357+
*
1358+
* Temporarily disable the bounds by changing the boolean `Camera.useBounds`.
1359+
*
1360+
* Clear the bounds entirely by calling `Camera.removeBounds`.
1361+
*
1362+
* If you set bounds that are smaller than the viewport it will stop the Camera from being
1363+
* able to scroll. The bounds can be positioned where-ever you wish. By default they are from
1364+
* 0x0 to the canvas width x height. This means that the coordinate 0x0 is the top left of
1365+
* the Camera bounds. However, you can position them anywhere. So if you wanted a game world
1366+
* that was 2048x2048 in size, with 0x0 being the center of it, you can set the bounds x/y
1367+
* to be -1024, -1024, with a width and height of 2048. Depending on your game you may find
1368+
* it easier for 0x0 to be the top-left of the bounds, or you may wish 0x0 to be the middle.
13241369
*
13251370
* @method Phaser.Cameras.Scene2D.Camera#setBounds
13261371
* @since 3.0.0
@@ -1329,15 +1374,26 @@ var Camera = new Class({
13291374
* @param {integer} y - The top-left y coordinate of the bounds.
13301375
* @param {integer} width - The width of the bounds, in pixels.
13311376
* @param {integer} height - The height of the bounds, in pixels.
1377+
* @param {boolean} [centerOn] - If `true` the Camera will automatically be centered on the new bounds.
13321378
*
13331379
* @return {Phaser.Cameras.Scene2D.Camera} This Camera instance.
13341380
*/
1335-
setBounds: function (x, y, width, height)
1381+
setBounds: function (x, y, width, height, centerOn)
13361382
{
13371383
this._bounds.setTo(x, y, width, height);
13381384

13391385
this.useBounds = true;
13401386

1387+
if (centerOn)
1388+
{
1389+
this.centerToBounds();
1390+
}
1391+
else
1392+
{
1393+
this.scrollX = this.clampX(this.scrollX);
1394+
this.scrollY = this.clampY(this.scrollY);
1395+
}
1396+
13411397
return this;
13421398
},
13431399

@@ -1406,8 +1462,9 @@ var Camera = new Class({
14061462
},
14071463

14081464
/**
1409-
* Should the Camera round pixel values to whole integers when scrolling?
1410-
* In some types of game this is required to prevent sub-pixel aliasing.
1465+
* Should the Camera round pixel values to whole integers when rendering Game Objects?
1466+
*
1467+
* In some types of game, especially with pixel art, this is required to prevent sub-pixel aliasing.
14111468
*
14121469
* @method Phaser.Cameras.Scene2D.Camera#setRoundPixels
14131470
* @since 3.0.0
@@ -1534,7 +1591,7 @@ var Camera = new Class({
15341591
* @method Phaser.Cameras.Scene2D.Camera#setZoom
15351592
* @since 3.0.0
15361593
*
1537-
* @param {float} [value=1] - The zoom value of the Camera. The minimum it can be is 0.001.
1594+
* @param {number} [value=1] - The zoom value of the Camera. The minimum it can be is 0.001.
15381595
*
15391596
* @return {Phaser.Cameras.Scene2D.Camera} This Camera instance.
15401597
*/
@@ -1590,8 +1647,8 @@ var Camera = new Class({
15901647
*
15911648
* @param {(Phaser.GameObjects.GameObject|object)} target - The target for the Camera to follow.
15921649
* @param {boolean} [roundPixels=false] - Round the camera position to whole integers to avoid sub-pixel rendering?
1593-
* @param {float} [lerpX=1] - A value between 0 and 1. This value specifies the amount of linear interpolation to use when horizontally tracking the target. The closer the value to 1, the faster the camera will track.
1594-
* @param {float} [lerpY=1] - A value between 0 and 1. This value specifies the amount of linear interpolation to use when vertically tracking the target. The closer the value to 1, the faster the camera will track.
1650+
* @param {number} [lerpX=1] - A value between 0 and 1. This value specifies the amount of linear interpolation to use when horizontally tracking the target. The closer the value to 1, the faster the camera will track.
1651+
* @param {number} [lerpY=1] - A value between 0 and 1. This value specifies the amount of linear interpolation to use when vertically tracking the target. The closer the value to 1, the faster the camera will track.
15951652
* @param {number} [offsetX=0] - The horizontal offset from the camera follow target.x position.
15961653
* @param {number} [offsetY=0] - The vertical offset from the camera follow target.y position.
15971654
*

0 commit comments

Comments
 (0)