From 5859979c967a789a187ef3f66f67d3fc361efbc4 Mon Sep 17 00:00:00 2001 From: TadejZupancic Date: Thu, 21 Jun 2018 14:07:18 +0200 Subject: [PATCH 01/48] Update GameObject.js --- src/gameobjects/GameObject.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gameobjects/GameObject.js b/src/gameobjects/GameObject.js index 05497d236..04a18945f 100644 --- a/src/gameobjects/GameObject.js +++ b/src/gameobjects/GameObject.js @@ -374,7 +374,7 @@ var GameObject = new Class({ { if (this.input) { - this.input.enabled = (this.input.enabled) ? false : true; + this.input.enabled = false; } return this; From 44a0813591910cf697453c4795332993cde05e48 Mon Sep 17 00:00:00 2001 From: rook2pawn Date: Wed, 13 Jun 2018 18:34:27 -0700 Subject: [PATCH 02/48] [feat] scene.run can now pass data to .wake and .resume if it needs to invoke those methods update javadoc for scene and scene systems --- src/scene/SceneManager.js | 10 +++++----- src/scene/Systems.js | 14 +++++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/scene/SceneManager.js b/src/scene/SceneManager.js index 00b515b99..a8df45666 100644 --- a/src/scene/SceneManager.js +++ b/src/scene/SceneManager.js @@ -140,7 +140,7 @@ var SceneManager = new Class({ }); } } - + game.events.once('ready', this.bootQueue, this); }, @@ -1011,7 +1011,7 @@ var SceneManager = new Class({ /** * Runs the given Scene, but does not change the state of this Scene. - * + * * If the given Scene is paused, it will resume it. If sleeping, it will wake it. * If not running at all, it will be started. * @@ -1022,7 +1022,7 @@ var SceneManager = new Class({ * @since 3.10.0 * * @param {string} key - The Scene to run. - * @param {object} [data] - A data object that will be passed to the Scene that is run _only if the Scene isn't asleep or paused_. + * @param {object} [data] - A data object that will be passed to the Scene on start, wake, or resume. * * @return {Phaser.Scenes.SceneManager} This Scene Manager. */ @@ -1038,12 +1038,12 @@ var SceneManager = new Class({ if (scene.sys.isSleeping()) { // Sleeping? - scene.sys.wake(); + scene.sys.wake(data); } else if (scene.sys.isBooted && !scene.sys.isActive()) { // Paused? - scene.sys.resume(); + scene.sys.resume(data); } else { diff --git a/src/scene/Systems.js b/src/scene/Systems.js index 46e01cf01..0c775c304 100644 --- a/src/scene/Systems.js +++ b/src/scene/Systems.js @@ -211,7 +211,7 @@ var Systems = new Class({ /** * The Scene Update function. - * + * * This starts out as NOOP during init, preload and create, and at the end of create * it swaps to be whatever the Scene.update function is. * @@ -368,9 +368,11 @@ var Systems = new Class({ * @method Phaser.Scenes.Systems#resume * @since 3.0.0 * + * @param {object} [data] - A data object that will be passed on the 'resume' event. + * * @return {Phaser.Scenes.Systems} This Systems object. */ - resume: function () + resume: function (data) { if (!this.settings.active) { @@ -378,7 +380,7 @@ var Systems = new Class({ this.settings.active = true; - this.events.emit('resume', this); + this.events.emit('resume', this, data); } return this; @@ -415,9 +417,11 @@ var Systems = new Class({ * @method Phaser.Scenes.Systems#wake * @since 3.0.0 * + * @param {object} [data] - A data object that will be passed on the 'wake' event. + * * @return {Phaser.Scenes.Systems} This Systems object. */ - wake: function () + wake: function (data) { var settings = this.settings; @@ -426,7 +430,7 @@ var Systems = new Class({ settings.active = true; settings.visible = true; - this.events.emit('wake', this); + this.events.emit('wake', this, data); if (settings.isTransition) { From 932737343b7cbca3494719f124d47595252400a7 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Sat, 23 Jun 2018 12:18:44 +0100 Subject: [PATCH 03/48] Added centerOn argument to setBounds and bumped Camera id to be public --- src/cameras/2d/Camera.js | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/cameras/2d/Camera.js b/src/cameras/2d/Camera.js index 821f2b753..0363db3dc 100644 --- a/src/cameras/2d/Camera.js +++ b/src/cameras/2d/Camera.js @@ -94,6 +94,16 @@ var Camera = new Class({ */ this.scene; + /** + * The Camera ID. Assigned by the Camera Manager and used to handle camera exclusion. + * + * @name Phaser.Cameras.Scene2D.Camera#id + * @type {integer} + * @readOnly + * @since 3.11.0 + */ + this.id = 0; + /** * The name of the Camera. This is left empty for your own use. * @@ -487,17 +497,6 @@ var Camera = new Class({ * @since 3.0.0 */ this._follow = null; - - /** - * Internal camera ID. Assigned by the Camera Manager and used in the camera pool. - * - * @name Phaser.Cameras.Scene2D.Camera#_id - * @type {integer} - * @private - * @default 0 - * @since 3.0.0 - */ - this._id = 0; }, /** @@ -1329,15 +1328,21 @@ var Camera = new Class({ * @param {integer} y - The top-left y coordinate of the bounds. * @param {integer} width - The width of the bounds, in pixels. * @param {integer} height - The height of the bounds, in pixels. + * @param {boolean} [centerOn] - If `true` the Camera will automatically be centered on the new bounds. * * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. */ - setBounds: function (x, y, width, height) + setBounds: function (x, y, width, height, centerOn) { this._bounds.setTo(x, y, width, height); this.useBounds = true; + if (centerOn) + { + this.centerToBounds(); + } + return this; }, From 5a0fe89a7ef4d32279a22c1ec305f1a911f4b18c Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Sat, 23 Jun 2018 12:26:39 +0100 Subject: [PATCH 04/48] Swap _id to id --- src/gameobjects/GameObject.js | 6 +++++- .../bitmaptext/dynamic/DynamicBitmapTextCanvasRenderer.js | 2 +- .../bitmaptext/static/BitmapTextCanvasRenderer.js | 2 +- src/gameobjects/blitter/BlitterCanvasRenderer.js | 2 +- src/gameobjects/graphics/GraphicsCanvasRenderer.js | 2 +- src/gameobjects/image/ImageCanvasRenderer.js | 2 +- src/gameobjects/image/ImageWebGLRenderer.js | 2 +- src/gameobjects/mesh/MeshWebGLRenderer.js | 2 +- src/gameobjects/sprite/SpriteCanvasRenderer.js | 2 +- src/gameobjects/sprite/SpriteWebGLRenderer.js | 2 +- src/gameobjects/text/static/TextCanvasRenderer.js | 2 +- src/gameobjects/text/static/TextWebGLRenderer.js | 2 +- src/gameobjects/tilesprite/TileSpriteCanvasRenderer.js | 2 +- src/gameobjects/tilesprite/TileSpriteWebGLRenderer.js | 2 +- .../dynamiclayer/DynamicTilemapLayerCanvasRenderer.js | 2 +- .../dynamiclayer/DynamicTilemapLayerWebGLRenderer.js | 2 +- .../staticlayer/StaticTilemapLayerCanvasRenderer.js | 2 +- src/tilemaps/staticlayer/StaticTilemapLayerWebGLRenderer.js | 2 +- 18 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/gameobjects/GameObject.js b/src/gameobjects/GameObject.js index 05497d236..2b948c594 100644 --- a/src/gameobjects/GameObject.js +++ b/src/gameobjects/GameObject.js @@ -124,7 +124,11 @@ var GameObject = new Class({ /** * A bitmask that controls if this Game Object is drawn by a Camera or not. - * Not usually set directly. Instead call `Camera.ignore`. + * Not usually set directly, instead call `Camera.ignore`, however you can + * set this property directly using the Camera.id property: + * + * @example + * this.cameraFilter |= camera.id * * @name Phaser.GameObjects.GameObject#cameraFilter * @type {number} diff --git a/src/gameobjects/bitmaptext/dynamic/DynamicBitmapTextCanvasRenderer.js b/src/gameobjects/bitmaptext/dynamic/DynamicBitmapTextCanvasRenderer.js index 6f7075003..f98cdd4ed 100644 --- a/src/gameobjects/bitmaptext/dynamic/DynamicBitmapTextCanvasRenderer.js +++ b/src/gameobjects/bitmaptext/dynamic/DynamicBitmapTextCanvasRenderer.js @@ -26,7 +26,7 @@ var DynamicBitmapTextCanvasRenderer = function (renderer, src, interpolationPerc var text = src.text; var textLength = text.length; - if (GameObject.RENDER_MASK !== src.renderFlags || textLength === 0 || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + if (GameObject.RENDER_MASK !== src.renderFlags || textLength === 0 || (src.cameraFilter > 0 && (src.cameraFilter & camera.id))) { return; } diff --git a/src/gameobjects/bitmaptext/static/BitmapTextCanvasRenderer.js b/src/gameobjects/bitmaptext/static/BitmapTextCanvasRenderer.js index 2921c96a8..88a557623 100644 --- a/src/gameobjects/bitmaptext/static/BitmapTextCanvasRenderer.js +++ b/src/gameobjects/bitmaptext/static/BitmapTextCanvasRenderer.js @@ -26,7 +26,7 @@ var BitmapTextCanvasRenderer = function (renderer, src, interpolationPercentage, var text = src.text; var textLength = text.length; - if (GameObject.RENDER_MASK !== src.renderFlags || textLength === 0 || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + if (GameObject.RENDER_MASK !== src.renderFlags || textLength === 0 || (src.cameraFilter > 0 && (src.cameraFilter & camera.id))) { return; } diff --git a/src/gameobjects/blitter/BlitterCanvasRenderer.js b/src/gameobjects/blitter/BlitterCanvasRenderer.js index ed2cd2172..b3d02ead4 100644 --- a/src/gameobjects/blitter/BlitterCanvasRenderer.js +++ b/src/gameobjects/blitter/BlitterCanvasRenderer.js @@ -23,7 +23,7 @@ var GameObject = require('../GameObject'); */ var BlitterCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera.id))) { return; } diff --git a/src/gameobjects/graphics/GraphicsCanvasRenderer.js b/src/gameobjects/graphics/GraphicsCanvasRenderer.js index 311831079..bda834c90 100644 --- a/src/gameobjects/graphics/GraphicsCanvasRenderer.js +++ b/src/gameobjects/graphics/GraphicsCanvasRenderer.js @@ -26,7 +26,7 @@ var GameObject = require('../GameObject'); */ var GraphicsCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix, renderTargetCtx, allowClip) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera.id))) { return; } diff --git a/src/gameobjects/image/ImageCanvasRenderer.js b/src/gameobjects/image/ImageCanvasRenderer.js index 95968f19f..269c78129 100644 --- a/src/gameobjects/image/ImageCanvasRenderer.js +++ b/src/gameobjects/image/ImageCanvasRenderer.js @@ -23,7 +23,7 @@ var GameObject = require('../GameObject'); */ var ImageCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera.id))) { return; } diff --git a/src/gameobjects/image/ImageWebGLRenderer.js b/src/gameobjects/image/ImageWebGLRenderer.js index 82c7d26d2..99c12f2fc 100644 --- a/src/gameobjects/image/ImageWebGLRenderer.js +++ b/src/gameobjects/image/ImageWebGLRenderer.js @@ -23,7 +23,7 @@ var GameObject = require('../GameObject'); */ var ImageWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera.id))) { return; } diff --git a/src/gameobjects/mesh/MeshWebGLRenderer.js b/src/gameobjects/mesh/MeshWebGLRenderer.js index ab71120d3..9f815ecc8 100644 --- a/src/gameobjects/mesh/MeshWebGLRenderer.js +++ b/src/gameobjects/mesh/MeshWebGLRenderer.js @@ -23,7 +23,7 @@ var GameObject = require('../GameObject'); */ var MeshWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera.id))) { return; } diff --git a/src/gameobjects/sprite/SpriteCanvasRenderer.js b/src/gameobjects/sprite/SpriteCanvasRenderer.js index 2f3e392b1..9263ef104 100644 --- a/src/gameobjects/sprite/SpriteCanvasRenderer.js +++ b/src/gameobjects/sprite/SpriteCanvasRenderer.js @@ -23,7 +23,7 @@ var GameObject = require('../GameObject'); */ var SpriteCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera.id))) { return; } diff --git a/src/gameobjects/sprite/SpriteWebGLRenderer.js b/src/gameobjects/sprite/SpriteWebGLRenderer.js index bdf7501cf..a9c850fba 100644 --- a/src/gameobjects/sprite/SpriteWebGLRenderer.js +++ b/src/gameobjects/sprite/SpriteWebGLRenderer.js @@ -23,7 +23,7 @@ var GameObject = require('../GameObject'); */ var SpriteWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera.id))) { return; } diff --git a/src/gameobjects/text/static/TextCanvasRenderer.js b/src/gameobjects/text/static/TextCanvasRenderer.js index 92ab7928f..96fa8e70b 100644 --- a/src/gameobjects/text/static/TextCanvasRenderer.js +++ b/src/gameobjects/text/static/TextCanvasRenderer.js @@ -23,7 +23,7 @@ var GameObject = require('../../GameObject'); */ var TextCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id)) || src.text === '') + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera.id)) || src.text === '') { return; } diff --git a/src/gameobjects/text/static/TextWebGLRenderer.js b/src/gameobjects/text/static/TextWebGLRenderer.js index d4def862c..eaad5be48 100644 --- a/src/gameobjects/text/static/TextWebGLRenderer.js +++ b/src/gameobjects/text/static/TextWebGLRenderer.js @@ -23,7 +23,7 @@ var GameObject = require('../../GameObject'); */ var TextWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id)) || src.text === '') + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera.id)) || src.text === '') { return; } diff --git a/src/gameobjects/tilesprite/TileSpriteCanvasRenderer.js b/src/gameobjects/tilesprite/TileSpriteCanvasRenderer.js index 4949a4577..736e147c3 100644 --- a/src/gameobjects/tilesprite/TileSpriteCanvasRenderer.js +++ b/src/gameobjects/tilesprite/TileSpriteCanvasRenderer.js @@ -23,7 +23,7 @@ var GameObject = require('../GameObject'); */ var TileSpriteCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera.id))) { return; } diff --git a/src/gameobjects/tilesprite/TileSpriteWebGLRenderer.js b/src/gameobjects/tilesprite/TileSpriteWebGLRenderer.js index 79108698a..d6d4d6369 100644 --- a/src/gameobjects/tilesprite/TileSpriteWebGLRenderer.js +++ b/src/gameobjects/tilesprite/TileSpriteWebGLRenderer.js @@ -23,7 +23,7 @@ var GameObject = require('../GameObject'); */ var TileSpriteWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera.id))) { return; } diff --git a/src/tilemaps/dynamiclayer/DynamicTilemapLayerCanvasRenderer.js b/src/tilemaps/dynamiclayer/DynamicTilemapLayerCanvasRenderer.js index 95d92dd01..50f73f893 100644 --- a/src/tilemaps/dynamiclayer/DynamicTilemapLayerCanvasRenderer.js +++ b/src/tilemaps/dynamiclayer/DynamicTilemapLayerCanvasRenderer.js @@ -22,7 +22,7 @@ var GameObject = require('../../gameobjects/GameObject'); */ var DynamicTilemapLayerCanvasRenderer = function (renderer, src, interpolationPercentage, camera) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera.id))) { return; } diff --git a/src/tilemaps/dynamiclayer/DynamicTilemapLayerWebGLRenderer.js b/src/tilemaps/dynamiclayer/DynamicTilemapLayerWebGLRenderer.js index d867e6151..961582c04 100644 --- a/src/tilemaps/dynamiclayer/DynamicTilemapLayerWebGLRenderer.js +++ b/src/tilemaps/dynamiclayer/DynamicTilemapLayerWebGLRenderer.js @@ -22,7 +22,7 @@ var GameObject = require('../../gameobjects/GameObject'); */ var DynamicTilemapLayerWebGLRenderer = function (renderer, src, interpolationPercentage, camera) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera.id))) { return; } diff --git a/src/tilemaps/staticlayer/StaticTilemapLayerCanvasRenderer.js b/src/tilemaps/staticlayer/StaticTilemapLayerCanvasRenderer.js index ab8b890ad..a881f5065 100644 --- a/src/tilemaps/staticlayer/StaticTilemapLayerCanvasRenderer.js +++ b/src/tilemaps/staticlayer/StaticTilemapLayerCanvasRenderer.js @@ -22,7 +22,7 @@ var GameObject = require('../../gameobjects/GameObject'); */ var StaticTilemapLayerCanvasRenderer = function (renderer, src, interpolationPercentage, camera) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera.id))) { return; } diff --git a/src/tilemaps/staticlayer/StaticTilemapLayerWebGLRenderer.js b/src/tilemaps/staticlayer/StaticTilemapLayerWebGLRenderer.js index 5c8add73d..72f7dc73a 100644 --- a/src/tilemaps/staticlayer/StaticTilemapLayerWebGLRenderer.js +++ b/src/tilemaps/staticlayer/StaticTilemapLayerWebGLRenderer.js @@ -22,7 +22,7 @@ var GameObject = require('../../gameobjects/GameObject'); */ var StaticTilemapLayerWebGLRenderer = function (renderer, src, interpolationPercentage, camera) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera.id))) { return; } From e53f61d0689713ce00f401fd9ab5be1c67553c89 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Sat, 23 Jun 2018 12:33:10 +0100 Subject: [PATCH 05/48] `CameraManager.resetAll` now destroys all current Cameras, resets the camera ID marker to 1 and adds a single new Camera. --- src/cameras/2d/CameraManager.js | 47 +++++++++------------------------ 1 file changed, 13 insertions(+), 34 deletions(-) diff --git a/src/cameras/2d/CameraManager.js b/src/cameras/2d/CameraManager.js index 5c6dc3d16..6326131b5 100644 --- a/src/cameras/2d/CameraManager.js +++ b/src/cameras/2d/CameraManager.js @@ -86,15 +86,6 @@ var CameraManager = new Class({ */ this.cameras = []; - /** - * A pool of Camera objects available to be used by the Camera Manager. - * - * @name Phaser.Cameras.Scene2D.CameraManager#cameraPool - * @type {Phaser.Cameras.Scene2D.Camera[]} - * @since 3.0.0 - */ - this.cameraPool = []; - /** * The default Camera in the Camera Manager. * @@ -191,18 +182,7 @@ var CameraManager = new Class({ if (makeMain === undefined) { makeMain = false; } if (name === undefined) { name = ''; } - var camera = null; - - if (this.cameraPool.length > 0) - { - camera = this.cameraPool.pop(); - - camera.setViewport(x, y, width, height); - } - else - { - camera = new Camera(x, y, width, height); - } + var camera = new Camera(x, y, width, height); camera.setName(name); camera.setScene(this.scene); @@ -214,7 +194,7 @@ var CameraManager = new Class({ this.main = camera; } - camera._id = this.currentCameraId; + camera.id = this.currentCameraId; this.currentCameraId = this.currentCameraId << 1; @@ -234,12 +214,14 @@ var CameraManager = new Class({ addExisting: function (camera) { var index = this.cameras.indexOf(camera); - var poolIndex = this.cameraPool.indexOf(camera); - if (index < 0 && poolIndex >= 0) + if (index == -1) { + camera.id = this.currentCameraId; + + this.currentCameraId = this.currentCameraId << 1; + this.cameras.push(camera); - this.cameraPool.slice(poolIndex, 1); return camera; } @@ -386,7 +368,6 @@ var CameraManager = new Class({ if (cameraIndex >= 0 && this.cameras.length > 1) { - this.cameraPool.push(this.cameras[cameraIndex]); this.cameras.splice(cameraIndex, 1); if (this.main === camera) @@ -434,11 +415,15 @@ var CameraManager = new Class({ */ resetAll: function () { - while (this.cameras.length > 0) + for (var i = 0; i < this.cameras.length; i++) { - this.cameraPool.push(this.cameras.pop()); + this.cameras[i].destroy(); } + this.cameras = []; + + this.currentCameraId = 1; + this.main = this.add(); return this.main; @@ -495,13 +480,7 @@ var CameraManager = new Class({ this.cameras[i].destroy(); } - for (i = 0; i < this.cameraPool.length; i++) - { - this.cameraPool[i].destroy(); - } - this.cameras = []; - this.cameraPool = []; var eventEmitter = this.systems.events; From 6df877cfa3fe2bcadb8315af0d5af207acae1c7b Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Sat, 23 Jun 2018 12:33:20 +0100 Subject: [PATCH 06/48] Docs update --- CHANGELOG.md | 17 ++++++++++++----- src/cameras/2d/Camera.js | 1 + 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 14c10ac4f..c7918965e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,15 +2,24 @@ ## Version 3.11.0 - Leafa - in development -### New Features +### Camera Specific New Features, Updates and Fixes -* `Graphics.fillRoundedRect` will draw a stroked rounded rectangle to a Graphics object. The radius of the corners can be either a number, or an object, allowing you to specify different radius per corner (thanks @TadejZupancic) -* `Graphics.strokeRoundedRect` will draw a filled rounded rectangle to a Graphics object. The radius of the corners can be either a number, or an object, allowing you to specify different radius per corner (thanks @TadejZupancic) * `Camera.deadzone` (and its related method `Camera.setDeadzone`) allows you to specify the deadzone for a camera. The deadzone is a rectangular region used when a camera is following a target. If the target is within the deadzone then the camera will not scroll. As soon as the target leaves the deadzone, the camera will begin tracking it (applying lerp if needed.) It allows you to set a region of the camera in which a player can move freely before tracking begins. The deadzone is re-centered on the camera mid point every frame, meaning you can also use the rectangle for other in-game chcecks as needed. * `Camera.midPoint` is a new Vec2 property that is updated every frame. Use it to obtain exactly where in the world the center of the camera is currently looking. * `Camera.displayWidth` is a new property that returns the display width of the camera, factoring in the current zoom level. * `Camera.displayHeight` is a new property that returns the display height of the camera, factoring in the current zoom level. * `Camera.centerOn` is a new method that will move the camera so its viewport is centered on the given coordinates. A handy way of jumping to different points around a map without needing to calculate the scroll offsets. +* The Camera bounds didn't factor in the camera zoom properly, meaning you would often not be able to reach the corners of a camera bound world at a zoom level other than 1. The bounds are now calculated each frame to ensure they match the zoom level and it will no longer allow you to scroll off the edge of the bounds. Fix #3547 (thanks @nkholski) +* `Camera.centerToBounds` didn't take the bounds offset into account, so bounds at non-zero positions wouldn't center properly. All bounds now center correctly. Fix #3706 (thanks @cyantree) +* `Camera.setBounds` has a new optional argument `centerOn`. If specified it will automatically center the camera on the new bounds given. +* `Camera._id` has been renamed to `Camera.id`, a read-only bitmask used for camera exclusion from Game Objects. +* The Camera Manager `cameraPool` has been removed entirely. It was mostly pointless in practise as Cameras are not regenerated frequently enough to need pooling. +* `CameraManager.resetAll` now destroys all current Cameras, resets the camera ID marker to 1 and adds a single new Camera. + +### New Features + +* `Graphics.fillRoundedRect` will draw a stroked rounded rectangle to a Graphics object. The radius of the corners can be either a number, or an object, allowing you to specify different radius per corner (thanks @TadejZupancic) +* `Graphics.strokeRoundedRect` will draw a filled rounded rectangle to a Graphics object. The radius of the corners can be either a number, or an object, allowing you to specify different radius per corner (thanks @TadejZupancic) ### Updates @@ -25,9 +34,7 @@ * The LoaderPlugin didn't emit the `filecomplete` event if any of files failed to load, causing it to fail to run the Scene `create` function as well. Fix #3750 (thanks @NokFrt) * Fix setter calls in BuildGameObjectAnimation so it will now properly set the delay, repeat, repeat delay and yoyo of a config based animation (thanks @DannyT) * The Arcade Body `blocked.none` property is now set to `false` after separation with static bodies or tiles. Previously, the blocked direction was set correctly, but the `none` remained `true` (thanks @samme) -* The Camera bounds didn't factor in the camera zoom properly, meaning you would often not be able to reach the corners of a camera bound world at a zoom level other than 1. The bounds are now calculated each frame to ensure they match the zoom level and it will no longer allow you to scroll off the edge of the bounds. Fix #3547 (thanks @nkholski) * `Bob.setFrame` didn't actually set the frame on the Bob, now it does. Fix #3774 (thanks @NokFrt) -* `Camera.centerToBounds` didn't take the bounds offset into account, so bounds at non-zero positions wouldn't center properly. All bounds now center correctly. Fix #3706 (thanks @cyantree) ### Examples, Documentation and TypeScript diff --git a/src/cameras/2d/Camera.js b/src/cameras/2d/Camera.js index 0363db3dc..f66ddd4c3 100644 --- a/src/cameras/2d/Camera.js +++ b/src/cameras/2d/Camera.js @@ -96,6 +96,7 @@ var Camera = new Class({ /** * The Camera ID. Assigned by the Camera Manager and used to handle camera exclusion. + * This value is a bitmask. * * @name Phaser.Cameras.Scene2D.Camera#id * @type {integer} From a73e47e508ca9bef0d293e334aacfbde6f039a60 Mon Sep 17 00:00:00 2001 From: Craig Whiteside Date: Sat, 23 Jun 2018 16:28:45 +0100 Subject: [PATCH 07/48] Account for position of tilemapLayer when culling tiles --- src/tilemaps/components/CullTiles.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tilemaps/components/CullTiles.js b/src/tilemaps/components/CullTiles.js index a372c371d..5249b414c 100644 --- a/src/tilemaps/components/CullTiles.js +++ b/src/tilemaps/components/CullTiles.js @@ -70,8 +70,8 @@ var CullTiles = function (layer, camera, outputArray) continue; } - var tileX = tile.pixelX * a + tile.pixelY * c + e; - var tileY = tile.pixelX * b + tile.pixelY * d + f; + var tileX = tilemapLayer.x + (tile.pixelX * a + tile.pixelY * c + e); + var tileY = tilemapLayer.y + (tile.pixelX * b + tile.pixelY * d + f); if (tile.visible && tileX >= tCullX && From 86f1cbcabfb0de3706db32107ece26216312c008 Mon Sep 17 00:00:00 2001 From: Craig Whiteside Date: Sat, 23 Jun 2018 16:34:45 +0100 Subject: [PATCH 08/48] Made it more specific to the tile offset. --- src/tilemaps/components/CullTiles.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tilemaps/components/CullTiles.js b/src/tilemaps/components/CullTiles.js index 5249b414c..41c989022 100644 --- a/src/tilemaps/components/CullTiles.js +++ b/src/tilemaps/components/CullTiles.js @@ -69,9 +69,9 @@ var CullTiles = function (layer, camera, outputArray) { continue; } - - var tileX = tilemapLayer.x + (tile.pixelX * a + tile.pixelY * c + e); - var tileY = tilemapLayer.y + (tile.pixelX * b + tile.pixelY * d + f); + + var tileX = ((tile.pixelX + tilemapLayer.x) * a + (tile.pixelY + tilemapLayer.y) * c + e); + var tileY = ((tile.pixelX + tilemapLayer.x) * b + (tile.pixelY + tilemapLayer.y) * d + f); if (tile.visible && tileX >= tCullX && From ac82e39314887b958febf00416429ee2c8d07be9 Mon Sep 17 00:00:00 2001 From: Craig Whiteside Date: Sat, 23 Jun 2018 16:40:19 +0100 Subject: [PATCH 09/48] Fix whitespace --- src/tilemaps/components/CullTiles.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tilemaps/components/CullTiles.js b/src/tilemaps/components/CullTiles.js index 41c989022..43b7ce0d7 100644 --- a/src/tilemaps/components/CullTiles.js +++ b/src/tilemaps/components/CullTiles.js @@ -69,7 +69,7 @@ var CullTiles = function (layer, camera, outputArray) { continue; } - + var tileX = ((tile.pixelX + tilemapLayer.x) * a + (tile.pixelY + tilemapLayer.y) * c + e); var tileY = ((tile.pixelX + tilemapLayer.x) * b + (tile.pixelY + tilemapLayer.y) * d + f); From bc2212c87d39a78daa2bd1ee0ad5c810fed7a312 Mon Sep 17 00:00:00 2001 From: samme Date: Sat, 23 Jun 2018 12:51:16 -0700 Subject: [PATCH 10/48] Add ParticleEmitter#stop() --- src/gameobjects/particles/ParticleEmitter.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/gameobjects/particles/ParticleEmitter.js b/src/gameobjects/particles/ParticleEmitter.js index 6b139a9fc..dd6ec3467 100644 --- a/src/gameobjects/particles/ParticleEmitter.js +++ b/src/gameobjects/particles/ParticleEmitter.js @@ -635,7 +635,7 @@ var ParticleEmitter = new Class({ /** * Controls if the emitter is currently emitting a particle flow (when frequency >= 0). * Already alive particles will continue to update until they expire. - * Controlled by {@link Phaser.GameObjects.Particles.ParticleEmitter#start}. + * Controlled by {@link Phaser.GameObjects.Particles.ParticleEmitter#start} and {@link Phaser.GameObjects.Particles.ParticleEmitter#stop}. * * @name Phaser.GameObjects.Particles.ParticleEmitter#on * @type {boolean} @@ -1862,6 +1862,21 @@ var ParticleEmitter = new Class({ return this; }, + /** + * Turns {@link Phaser.GameObjects.Particles.ParticleEmitter#on off} the emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#stop + * @since 3.11.0 + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + stop: function () + { + this.on = false; + + return this; + }, + /** * {@link Phaser.GameObjects.Particles.ParticleEmitter#active Deactivates} the emitter. * From 375b1f8f182ca0d633a5a80867615e759ea7960f Mon Sep 17 00:00:00 2001 From: Craig Whiteside Date: Sat, 23 Jun 2018 21:20:54 +0100 Subject: [PATCH 11/48] Pulled out calculation for tile pixel position amended with tilemapLayer position --- src/tilemaps/components/CullTiles.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/tilemaps/components/CullTiles.js b/src/tilemaps/components/CullTiles.js index 43b7ce0d7..6ec3bc118 100644 --- a/src/tilemaps/components/CullTiles.js +++ b/src/tilemaps/components/CullTiles.js @@ -70,8 +70,10 @@ var CullTiles = function (layer, camera, outputArray) continue; } - var tileX = ((tile.pixelX + tilemapLayer.x) * a + (tile.pixelY + tilemapLayer.y) * c + e); - var tileY = ((tile.pixelX + tilemapLayer.x) * b + (tile.pixelY + tilemapLayer.y) * d + f); + var tilePixelX = (tile.pixelX + tilemapLayer.x); + var tilePixelY = (tile.pixelY + tilemapLayer.y); + var tileX = (tilePixelX * a + tilePixelY * c + e); + var tileY = (tilePixelX * b + tilePixelY * d + f); if (tile.visible && tileX >= tCullX && From 3b3005926af03409dcff3ccf1b3515dfec56769a Mon Sep 17 00:00:00 2001 From: Chris Andrew Date: Sun, 24 Jun 2018 00:55:57 +0100 Subject: [PATCH 12/48] Updated change log. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 14c10ac4f..70454a471 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ * The Camera bounds didn't factor in the camera zoom properly, meaning you would often not be able to reach the corners of a camera bound world at a zoom level other than 1. The bounds are now calculated each frame to ensure they match the zoom level and it will no longer allow you to scroll off the edge of the bounds. Fix #3547 (thanks @nkholski) * `Bob.setFrame` didn't actually set the frame on the Bob, now it does. Fix #3774 (thanks @NokFrt) * `Camera.centerToBounds` didn't take the bounds offset into account, so bounds at non-zero positions wouldn't center properly. All bounds now center correctly. Fix #3706 (thanks @cyantree) +* `SceneManager.run` would ignore scenes that are currently in the queue of scenes pending to be added. This has now been fixed so that the scene is queued to be started once it's ready (thanks @rook2pawn) ### Examples, Documentation and TypeScript From 9a96785cf64a4f1325b54ed8bab10eb34e24aa35 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Mon, 25 Jun 2018 15:38:06 +0100 Subject: [PATCH 13/48] If the Blitter object has no Bob's to render it will now abort immediately, avoiding several context calls in Canvas mode. --- .../blitter/BlitterCanvasRenderer.js | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/gameobjects/blitter/BlitterCanvasRenderer.js b/src/gameobjects/blitter/BlitterCanvasRenderer.js index b3d02ead4..1633ed040 100644 --- a/src/gameobjects/blitter/BlitterCanvasRenderer.js +++ b/src/gameobjects/blitter/BlitterCanvasRenderer.js @@ -23,12 +23,29 @@ var GameObject = require('../GameObject'); */ var BlitterCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera.id))) + var list = src.getRenderList(); + + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera.id)) || list.length === 0) { return; } - var list = src.getRenderList(); + // Alpha + + var alpha = camera.alpha * src.alpha; + + if (alpha === 0) + { + // Nothing to see, so abort early + return; + } + else if (renderer.currentAlpha !== alpha) + { + renderer.currentAlpha = alpha; + ctx.globalAlpha = alpha; + } + + // Blend Mode renderer.setBlendMode(src.blendMode); From bcacfeb87cff0c9edc0f21e6f233406a0c5d8d61 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Mon, 25 Jun 2018 15:59:01 +0100 Subject: [PATCH 14/48] `Bob.alpha` was ignored by the canvas renderer, only working in WebGL. This has now been fixed. --- src/gameobjects/blitter/BlitterCanvasRenderer.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/gameobjects/blitter/BlitterCanvasRenderer.js b/src/gameobjects/blitter/BlitterCanvasRenderer.js index 1633ed040..515e54c3d 100644 --- a/src/gameobjects/blitter/BlitterCanvasRenderer.js +++ b/src/gameobjects/blitter/BlitterCanvasRenderer.js @@ -30,6 +30,8 @@ var BlitterCanvasRenderer = function (renderer, src, interpolationPercentage, ca return; } + var ctx = renderer.gameContext; + // Alpha var alpha = camera.alpha * src.alpha; @@ -49,7 +51,6 @@ var BlitterCanvasRenderer = function (renderer, src, interpolationPercentage, ca renderer.setBlendMode(src.blendMode); - var ctx = renderer.gameContext; var cameraScrollX = src.x - camera.scrollX * src.scrollFactorX; var cameraScrollY = src.y - camera.scrollY * src.scrollFactorY; @@ -73,6 +74,18 @@ var BlitterCanvasRenderer = function (renderer, src, interpolationPercentage, ca var fx = 1; var fy = 1; + var bobAlpha = bob.alpha * alpha; + + if (bobAlpha === 0) + { + continue; + } + else if (renderer.currentAlpha !== bobAlpha) + { + renderer.currentAlpha = bobAlpha; + ctx.globalAlpha = bobAlpha; + } + if (!flip) { renderer.blitImage(dx + bob.x + cameraScrollX, dy + bob.y + cameraScrollY, bob.frame); From 98b1cc2dbc7d418e2a7f8ad374c339117b104281 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Mon, 25 Jun 2018 16:06:22 +0100 Subject: [PATCH 15/48] Although the Blitter object had the Alpha component, setting it made no difference. Setting Blitter alpha now impacts the rendering of all children, in both Canvas and WebGL, and you can also specify an alpha per Bob as well. --- src/renderer/webgl/pipelines/TextureTintPipeline.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/renderer/webgl/pipelines/TextureTintPipeline.js b/src/renderer/webgl/pipelines/TextureTintPipeline.js index fa9a8a059..2e2ec95b8 100644 --- a/src/renderer/webgl/pipelines/TextureTintPipeline.js +++ b/src/renderer/webgl/pipelines/TextureTintPipeline.js @@ -665,6 +665,8 @@ var TextureTintPipeline = new Class({ var prevTextureSourceIndex; + var alpha = camera.alpha * blitter.alpha; + for (var batchIndex = 0; batchIndex < batchCount; ++batchIndex) { var batchSize = Math.min(length, this.maxQuads); @@ -673,15 +675,15 @@ var TextureTintPipeline = new Class({ { var bob = list[batchOffset + index]; var frame = bob.frame; - var alpha = bob.alpha; + var bobAlpha = bob.alpha * alpha; - if (alpha === 0) + if (bobAlpha === 0) { // Nothing to see here, moving on ... continue; } - var tint = getTint(0xffffff, alpha); + var tint = getTint(0xffffff, bobAlpha); var uvs = frame.uvs; var flipX = bob.flipX; var flipY = bob.flipY; From 0c55745206f56fcda31fd54d649ff7a4c93ab525 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Mon, 25 Jun 2018 16:06:31 +0100 Subject: [PATCH 16/48] Updated log --- CHANGELOG.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c7918965e..dad5c939f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Version 3.11.0 - Leafa - in development -### Camera Specific New Features, Updates and Fixes +### Camera - New Features, Updates and Fixes * `Camera.deadzone` (and its related method `Camera.setDeadzone`) allows you to specify the deadzone for a camera. The deadzone is a rectangular region used when a camera is following a target. If the target is within the deadzone then the camera will not scroll. As soon as the target leaves the deadzone, the camera will begin tracking it (applying lerp if needed.) It allows you to set a region of the camera in which a player can move freely before tracking begins. The deadzone is re-centered on the camera mid point every frame, meaning you can also use the rectangle for other in-game chcecks as needed. * `Camera.midPoint` is a new Vec2 property that is updated every frame. Use it to obtain exactly where in the world the center of the camera is currently looking. @@ -13,8 +13,10 @@ * `Camera.centerToBounds` didn't take the bounds offset into account, so bounds at non-zero positions wouldn't center properly. All bounds now center correctly. Fix #3706 (thanks @cyantree) * `Camera.setBounds` has a new optional argument `centerOn`. If specified it will automatically center the camera on the new bounds given. * `Camera._id` has been renamed to `Camera.id`, a read-only bitmask used for camera exclusion from Game Objects. -* The Camera Manager `cameraPool` has been removed entirely. It was mostly pointless in practise as Cameras are not regenerated frequently enough to need pooling. +* The Camera Manager `cameraPool` has been removed entirely. It was mostly pointless in practise as Cameras are not regenerated frequently enough to need pooling. It also didn't maintain the bitmask list correctly before. * `CameraManager.resetAll` now destroys all current Cameras, resets the camera ID marker to 1 and adds a single new Camera. +* `CameraManager.currentCameraId` has been renamed to `nextID` and marked as read-only. +* `addExisting` has new property `makeMain`. ### New Features @@ -26,7 +28,8 @@ * DataManager.removeValue (and by extension the `remove` method too) will not emit the parent of the DataManager as the 2nd argument in the `removedata` event, to keep it consistent with the set events (thanks @rexrainbow) * The docs for the Loader `filecomplete` event said that you could listen for a specific file using its type and key, i.e.: `filecomplete-image-monster`, however, the code used an underscore instead of a hyphen. We feel the hyphen looks cleaner, so the Loader code has been updated, meaning you can now use the hyphen version of the event properly (thanks @NokFrt) * If a Game Object is already being dragged, it cannot be dragged by another pointer (in multi-touch mode) until the original pointer has released it (thanks @rexrainbow) -* Calling `Tween.play` on a tween created via `TweenManager.create` wouldn't actually start playback until the tween was first added to the Tween Manager. Now, calling `play` will have it automatically add itself to the Tween Manager if it's not already in there. Fix #3763 (thanks @pantoninho) +* Calling `Tween.play` on a tween created via `TweenManager.create` wouldn't actually start playback until the tween was first added to the Tween Manager. Now, calling `play` will have it automatically add itself to the Tween Manager if it's not already in there. Fix #3763 (thanks @pantoninho) +* If the Blitter object has no Bob's to render it will now abort immediately, avoiding several context calls in Canvas mode. ### Bug Fixes @@ -35,6 +38,8 @@ * Fix setter calls in BuildGameObjectAnimation so it will now properly set the delay, repeat, repeat delay and yoyo of a config based animation (thanks @DannyT) * The Arcade Body `blocked.none` property is now set to `false` after separation with static bodies or tiles. Previously, the blocked direction was set correctly, but the `none` remained `true` (thanks @samme) * `Bob.setFrame` didn't actually set the frame on the Bob, now it does. Fix #3774 (thanks @NokFrt) +* `Bob.alpha` was ignored by the canvas renderer, only working in WebGL. This has now been fixed. +* Although the Blitter object had the Alpha component, setting it made no difference. Setting Blitter alpha now impacts the rendering of all children, in both Canvas and WebGL, and you can also specify an alpha per Bob as well. ### Examples, Documentation and TypeScript From d20188b75d98423b3b5c64042226a0d27dfc65c9 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Mon, 25 Jun 2018 16:10:50 +0100 Subject: [PATCH 17/48] Removed camera pool, renamed current ID and added accessor properties --- CHANGELOG.md | 3 +- src/cameras/2d/CameraManager.js | 266 +++++++++++++++++++++++++++++--- 2 files changed, 243 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dad5c939f..647f65833 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,8 @@ * The Camera Manager `cameraPool` has been removed entirely. It was mostly pointless in practise as Cameras are not regenerated frequently enough to need pooling. It also didn't maintain the bitmask list correctly before. * `CameraManager.resetAll` now destroys all current Cameras, resets the camera ID marker to 1 and adds a single new Camera. * `CameraManager.currentCameraId` has been renamed to `nextID` and marked as read-only. -* `addExisting` has new property `makeMain`. +* `CameraManager.addExisting` no longer needs to be passed a Camera that already exists in the pool (as the pool has been removed), meaning you can now create your own Cameras and pass them to `addExisting` and have them treated as normal cameras and not be ignored by the manager. They are also assigned a proper ID when added. +* `CameraManager.addExisting` has a new boolean argument `makeMain` which will make the new camera the main one. ### New Features diff --git a/src/cameras/2d/CameraManager.js b/src/cameras/2d/CameraManager.js index 6326131b5..a1170a96d 100644 --- a/src/cameras/2d/CameraManager.js +++ b/src/cameras/2d/CameraManager.js @@ -31,6 +31,9 @@ var RectangleContains = require('../../geom/rectangle/Contains'); * @property {number} [bounds.height] - [description] */ +// TODO stop it assigning more than 32 cameras (or whatever the limit is) +// The remove method leaves gaps in the ID list + /** * @classdesc * [description] @@ -67,18 +70,22 @@ var CameraManager = new Class({ this.systems = scene.sys; /** - * The current Camera ID. + * The ID that will be assigned to the next Camera that is created. + * This is a bitmask value, meaning only up to 31 cameras can be created in total. * - * @name Phaser.Cameras.Scene2D.CameraManager#currentCameraId - * @type {number} + * @name Phaser.Cameras.Scene2D.CameraManager#nextID + * @type {integer} * @default 1 * @readOnly * @since 3.0.0 */ - this.currentCameraId = 1; + this.nextID = 1; /** * An Array of the Camera objects being managed by this Camera Manager. + * The Cameras are updated and rendered in the same order in which they appear in this array. + * Do not directly add or remove entries to this array. However, you can move the contents + * around the array should you wish to adjust the display order. * * @name Phaser.Cameras.Scene2D.CameraManager#cameras * @type {Phaser.Cameras.Scene2D.Camera[]} @@ -87,7 +94,15 @@ var CameraManager = new Class({ this.cameras = []; /** - * The default Camera in the Camera Manager. + * A handy reference to the 'main' camera. By default this is the first Camera the + * Camera Manager creates. You can also set it directly, or use the `makeMain` argument + * in the `add` and `addExisting` methods. It allows you to access it from your game: + * + * ```javascript + * var cam = this.cameras.main; + * ``` + * + * Also see the properties `camera1`, `camera2` and so on. * * @name Phaser.Cameras.Scene2D.CameraManager#main * @type {Phaser.Cameras.Scene2D.Camera} @@ -96,7 +111,7 @@ var CameraManager = new Class({ this.main; /** - * This scale affects all cameras. It's used by Scale Manager. + * This scale affects all cameras. It's used by the Scale Manager. * * @name Phaser.Cameras.Scene2D.CameraManager#baseScale * @type {number} @@ -194,9 +209,9 @@ var CameraManager = new Class({ this.main = camera; } - camera.id = this.currentCameraId; + camera.id = this.nextID; - this.currentCameraId = this.currentCameraId << 1; + this.nextID = this.nextID << 1; return camera; }, @@ -208,21 +223,29 @@ var CameraManager = new Class({ * @since 3.0.0 * * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * @param {boolean} [makeMain=false] - [description] * * @return {Phaser.Cameras.Scene2D.Camera} [description] */ - addExisting: function (camera) + addExisting: function (camera, makeMain) { + if (makeMain === undefined) { makeMain = false; } + var index = this.cameras.indexOf(camera); - if (index == -1) + if (index === -1) { - camera.id = this.currentCameraId; - - this.currentCameraId = this.currentCameraId << 1; - this.cameras.push(camera); + camera.id = this.nextID; + + this.nextID = this.nextID << 1; + + if (makeMain) + { + this.main = camera; + } + return camera; } @@ -304,15 +327,17 @@ var CameraManager = new Class({ * * @param {string} name - [description] * - * @return {Phaser.Cameras.Scene2D.Camera} [description] + * @return {?Phaser.Cameras.Scene2D.Camera} [description] */ getCamera: function (name) { - for (var i = 0; i < this.cameras.length; i++) + var cameras = this.cameras; + + for (var i = 0; i < cameras.length; i++) { - if (this.cameras[i].name === name) + if (cameras[i].name === name) { - return this.cameras[i]; + return cameras[i]; } } @@ -389,18 +414,20 @@ var CameraManager = new Class({ */ render: function (renderer, children, interpolation) { + var scene = this.scene; var cameras = this.cameras; var baseScale = this.baseScale; + var resolution = renderer.config.resolution; - for (var i = 0, l = cameras.length; i < l; ++i) + for (var i = 0; i < this.cameras.length; i++) { var camera = cameras[i]; - if (camera.visible) + if (camera.visible && camera.alpha > 0) { - camera.preRender(baseScale, renderer.config.resolution); + camera.preRender(baseScale, resolution); - renderer.render(this.scene, children, interpolation, camera); + renderer.render(scene, children, interpolation, camera); } } }, @@ -422,7 +449,7 @@ var CameraManager = new Class({ this.cameras = []; - this.currentCameraId = 1; + this.nextID = 1; this.main = this.add(); @@ -440,7 +467,7 @@ var CameraManager = new Class({ */ update: function (timestep, delta) { - for (var i = 0, l = this.cameras.length; i < l; ++i) + for (var i = 0; i < this.cameras.length; i++) { this.cameras[i].update(timestep, delta); } @@ -457,7 +484,7 @@ var CameraManager = new Class({ */ resize: function (width, height) { - for (var i = 0, l = this.cameras.length; i < l; ++i) + for (var i = 0; i < this.cameras.length; i++) { this.cameras[i].setSize(width, height); } @@ -504,6 +531,195 @@ var CameraManager = new Class({ this.scene = null; this.systems = null; + }, + + /** + * A reference to Camera 1 in the Camera Manager. + * + * Create additional cameras using the `add` method. + * + * @name Phaser.Cameras.Scene2D.CameraManager#camera1 + * @type {Phaser.Cameras.Scene2D.Camera} + * @readOnly + * @since 3.11.0 + */ + camera1: { + + get: function () + { + return this.cameras[0]; + } + + }, + + /** + * A reference to Camera 2 in the Camera Manager. + * + * This will be `undefined` by default unless you have created new cameras via `add` or `addExisting`. + * + * @name Phaser.Cameras.Scene2D.CameraManager#camera2 + * @type {Phaser.Cameras.Scene2D.Camera} + * @readOnly + * @since 3.11.0 + */ + camera2: { + + get: function () + { + return this.cameras[1]; + } + + }, + + /** + * A reference to Camera 3 in the Camera Manager. + * + * This will be `undefined` by default unless you have created new cameras via `add` or `addExisting`. + * + * @name Phaser.Cameras.Scene2D.CameraManager#camera3 + * @type {Phaser.Cameras.Scene2D.Camera} + * @readOnly + * @since 3.11.0 + */ + camera3: { + + get: function () + { + return this.cameras[2]; + } + + }, + + /** + * A reference to Camera 4 in the Camera Manager. + * + * This will be `undefined` by default unless you have created new cameras via `add` or `addExisting`. + * + * @name Phaser.Cameras.Scene2D.CameraManager#camera4 + * @type {Phaser.Cameras.Scene2D.Camera} + * @readOnly + * @since 3.11.0 + */ + camera4: { + + get: function () + { + return this.cameras[3]; + } + + }, + + /** + * A reference to Camera 5 in the Camera Manager. + * + * This will be `undefined` by default unless you have created new cameras via `add` or `addExisting`. + * + * @name Phaser.Cameras.Scene2D.CameraManager#camera5 + * @type {Phaser.Cameras.Scene2D.Camera} + * @readOnly + * @since 3.11.0 + */ + camera5: { + + get: function () + { + return this.cameras[4]; + } + + }, + + /** + * A reference to Camera 6 in the Camera Manager. + * + * This will be `undefined` by default unless you have created new cameras via `add` or `addExisting`. + * + * @name Phaser.Cameras.Scene2D.CameraManager#camera6 + * @type {Phaser.Cameras.Scene2D.Camera} + * @readOnly + * @since 3.11.0 + */ + camera6: { + + get: function () + { + return this.cameras[5]; + } + + }, + + /** + * A reference to Camera 7 in the Camera Manager. + * + * This will be `undefined` by default unless you have created new cameras via `add` or `addExisting`. + * + * @name Phaser.Cameras.Scene2D.CameraManager#camera7 + * @type {Phaser.Cameras.Scene2D.Camera} + * @readOnly + * @since 3.11.0 + */ + camera7: { + + get: function () + { + return this.cameras[6]; + } + + }, + + /** + * A reference to Camera 8 in the Camera Manager. + * + * This will be `undefined` by default unless you have created new cameras via `add` or `addExisting`. + * + * @name Phaser.Cameras.Scene2D.CameraManager#camera8 + * @type {Phaser.Cameras.Scene2D.Camera} + * @readOnly + * @since 3.11.0 + */ + camera8: { + + get: function () + { + return this.cameras[7]; + } + + }, + + /** + * A reference to Camera 9 in the Camera Manager. + * + * This will be `undefined` by default unless you have created new cameras via `add` or `addExisting`. + * + * @name Phaser.Cameras.Scene2D.CameraManager#camera9 + * @type {Phaser.Cameras.Scene2D.Camera} + * @readOnly + * @since 3.11.0 + */ + camera9: { + + get: function () + { + return this.cameras[8]; + } + + }, + /** + * A reference to Camera 10 in the Camera Manager. + * + * This will be `undefined` by default unless you have created new cameras via `add` or `addExisting`. + * + * @name Phaser.Cameras.Scene2D.CameraManager#camera10 + * @type {Phaser.Cameras.Scene2D.Camera} + * @readOnly + * @since 3.11.0 + */ + camera10: { + + get: function () + { + return this.cameras[9]; + } + } }); From 6dff47b71d2c12042940357552bf7ee8d729568f Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Mon, 25 Jun 2018 16:11:09 +0100 Subject: [PATCH 18/48] Added Camera.alpha property --- src/cameras/2d/Camera.js | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/src/cameras/2d/Camera.js b/src/cameras/2d/Camera.js index f66ddd4c3..a835c032d 100644 --- a/src/cameras/2d/Camera.js +++ b/src/cameras/2d/Camera.js @@ -313,6 +313,16 @@ var Camera = new Class({ */ this.backgroundColor = ValueToColor('rgba(0,0,0,0)'); + /** + * The Camera alpha value. + * + * @name Phaser.Cameras.Scene2D.Camera#alpha + * @type {number} + * @default 1 + * @since 3.11.0 + */ + this.alpha = 1; + /** * The Camera Fade effect handler. * To fade this camera see the `Camera.fade` methods. @@ -1317,10 +1327,23 @@ var Camera = new Class({ }, /** - * Set the world bounds for this Camera. - * - * A Camera bounds controls where the camera can scroll to within the world. It does not limit - * rendering of the camera, or placement of the viewport within your game. + * Set the bounds of the Camera. The bounds are an axis-aligned rectangle. + * + * The Camera bounds controls where the Camera can scroll to, stopping it from scrolling off the + * edges and into blank space. It does not limit the placement of Game Objects, or where + * the Camera viewport can be positioned. + * + * Temporarily disable the bounds by changing the boolean `Camera.useBounds`. + * + * Clear the bounds entirely by calling `Camera.removeBounds`. + * + * If you set bounds that are smaller than the viewport it will stop the Camera from being + * able to scroll. The bounds can be positioned where-ever you wish. By default they are from + * 0x0 to the canvas width x height. This means that the coordinate 0x0 is the top left of + * the Camera bounds. However, you can position them anywhere. So if you wanted a game world + * that was 2048x2048 in size, with 0x0 being the center of it, you can set the bounds x/y + * to be -1024, -1024, with a width and height of 2048. Depending on your game you may find + * it easier for 0x0 to be the top-left of the bounds, or you may wish 0x0 to be the middle. * * @method Phaser.Cameras.Scene2D.Camera#setBounds * @since 3.0.0 @@ -1343,6 +1366,11 @@ var Camera = new Class({ { this.centerToBounds(); } + else + { + this.scrollX = this.clampX(this.scrollX); + this.scrollY = this.clampY(this.scrollY); + } return this; }, From 90ba2608fa655046fc059a3a6e1e652a973d7375 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Mon, 25 Jun 2018 16:24:08 +0100 Subject: [PATCH 19/48] Added in Camera alpha support to all canvas renderers --- .../DynamicBitmapTextCanvasRenderer.js | 15 ++++++++++ .../static/BitmapTextCanvasRenderer.js | 22 +++++++++----- .../graphics/GraphicsCanvasRenderer.js | 29 ++++++++++++------- .../ParticleManagerCanvasRenderer.js | 10 ++++--- .../RenderTextureCanvasRenderer.js | 26 +++++++++++++---- .../text/static/TextCanvasRenderer.js | 24 ++++++++++----- .../tilesprite/TileSpriteCanvasRenderer.js | 23 ++++++++++----- src/renderer/canvas/CanvasRenderer.js | 9 +++--- src/renderer/canvas/utils/DrawImage.js | 23 ++++++++++----- 9 files changed, 125 insertions(+), 56 deletions(-) diff --git a/src/gameobjects/bitmaptext/dynamic/DynamicBitmapTextCanvasRenderer.js b/src/gameobjects/bitmaptext/dynamic/DynamicBitmapTextCanvasRenderer.js index f98cdd4ed..23d302139 100644 --- a/src/gameobjects/bitmaptext/dynamic/DynamicBitmapTextCanvasRenderer.js +++ b/src/gameobjects/bitmaptext/dynamic/DynamicBitmapTextCanvasRenderer.js @@ -68,6 +68,21 @@ var DynamicBitmapTextCanvasRenderer = function (renderer, src, interpolationPerc var rotation = 0; var scale = (src.fontSize / src.fontData.size); + // Alpha + + var alpha = camera.alpha * src.alpha; + + if (alpha === 0) + { + // Nothing to see, so abort early + return; + } + else if (renderer.currentAlpha !== alpha) + { + renderer.currentAlpha = alpha; + ctx.globalAlpha = alpha; + } + // Blend Mode if (renderer.currentBlendMode !== src.blendMode) { diff --git a/src/gameobjects/bitmaptext/static/BitmapTextCanvasRenderer.js b/src/gameobjects/bitmaptext/static/BitmapTextCanvasRenderer.js index 88a557623..c5471a834 100644 --- a/src/gameobjects/bitmaptext/static/BitmapTextCanvasRenderer.js +++ b/src/gameobjects/bitmaptext/static/BitmapTextCanvasRenderer.js @@ -63,6 +63,21 @@ var BitmapTextCanvasRenderer = function (renderer, src, interpolationPercentage, var scale = (src.fontSize / src.fontData.size); + // Alpha + + var alpha = camera.alpha * src.alpha; + + if (alpha === 0) + { + // Nothing to see, so abort early + return; + } + else if (renderer.currentAlpha !== alpha) + { + renderer.currentAlpha = alpha; + ctx.globalAlpha = alpha; + } + // Blend Mode if (renderer.currentBlendMode !== src.blendMode) { @@ -70,13 +85,6 @@ var BitmapTextCanvasRenderer = function (renderer, src, interpolationPercentage, ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; } - // Alpha - if (renderer.currentAlpha !== src.alpha) - { - renderer.currentAlpha = src.alpha; - ctx.globalAlpha = src.alpha; - } - // Smoothing if (renderer.currentScaleMode !== src.scaleMode) { diff --git a/src/gameobjects/graphics/GraphicsCanvasRenderer.js b/src/gameobjects/graphics/GraphicsCanvasRenderer.js index bda834c90..01a49c430 100644 --- a/src/gameobjects/graphics/GraphicsCanvasRenderer.js +++ b/src/gameobjects/graphics/GraphicsCanvasRenderer.js @@ -49,6 +49,21 @@ var GraphicsCanvasRenderer = function (renderer, src, interpolationPercentage, c var green = 0; var blue = 0; + // Alpha + + var alpha = camera.alpha * src.alpha; + + if (alpha === 0) + { + // Nothing to see, so abort early + return; + } + else if (renderer.currentAlpha !== alpha) + { + renderer.currentAlpha = alpha; + ctx.globalAlpha = alpha; + } + // Blend Mode if (renderer.currentBlendMode !== src.blendMode) { @@ -56,13 +71,6 @@ var GraphicsCanvasRenderer = function (renderer, src, interpolationPercentage, c ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; } - // Alpha - if (renderer.currentAlpha !== src.alpha) - { - renderer.currentAlpha = src.alpha; - ctx.globalAlpha = src.alpha; - } - // Smoothing if (renderer.currentScaleMode !== src.scaleMode) { @@ -70,11 +78,14 @@ var GraphicsCanvasRenderer = function (renderer, src, interpolationPercentage, c } ctx.save(); + if (parentMatrix) { var matrix = parentMatrix.matrix; + ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); } + ctx.translate(srcX - cameraScrollX, srcY - cameraScrollY); ctx.rotate(srcRotation); ctx.scale(srcScaleX, srcScaleY); @@ -253,10 +264,6 @@ var GraphicsCanvasRenderer = function (renderer, src, interpolationPercentage, c ); index += 1; break; - - default: - // console.error('Phaser: Invalid Graphics Command ID ' + commandID); - break; } } diff --git a/src/gameobjects/particles/ParticleManagerCanvasRenderer.js b/src/gameobjects/particles/ParticleManagerCanvasRenderer.js index a5103614d..d7e65134d 100644 --- a/src/gameobjects/particles/ParticleManagerCanvasRenderer.js +++ b/src/gameobjects/particles/ParticleManagerCanvasRenderer.js @@ -33,9 +33,11 @@ var ParticleManagerCanvasRenderer = function (renderer, emitterManager, interpol var ctx = renderer.currentContext; ctx.save(); + if (parentMatrix !== undefined) { var matrix = parentMatrix.matrix; + ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); } @@ -51,8 +53,8 @@ var ParticleManagerCanvasRenderer = function (renderer, emitterManager, interpol continue; } - var lastAlpha = ctx.globalAlpha; + var cameraScrollX = camera.scrollX * emitter.scrollFactorX; var cameraScrollY = camera.scrollY * emitter.scrollFactorY; @@ -68,9 +70,9 @@ var ParticleManagerCanvasRenderer = function (renderer, emitterManager, interpol { var particle = particles[index]; - var alpha = ((particle.color >> 24) & 0xFF) / 255.0; + var particleAlpha = camera.alpha * ((particle.color >> 24) & 0xFF) / 255; - if (alpha <= 0) + if (particleAlpha <= 0) { continue; } @@ -94,7 +96,7 @@ var ParticleManagerCanvasRenderer = function (renderer, emitterManager, interpol ty |= 0; } - ctx.globalAlpha = alpha; + ctx.globalAlpha = particleAlpha; ctx.save(); diff --git a/src/gameobjects/rendertexture/RenderTextureCanvasRenderer.js b/src/gameobjects/rendertexture/RenderTextureCanvasRenderer.js index a8c63af01..3e77d0352 100644 --- a/src/gameobjects/rendertexture/RenderTextureCanvasRenderer.js +++ b/src/gameobjects/rendertexture/RenderTextureCanvasRenderer.js @@ -30,17 +30,30 @@ var RenderTextureCanvasRenderer = function (renderer, renderTexture, interpolati var ctx = renderer.currentContext; + // Alpha + + var alpha = camera.alpha * renderTexture.alpha; + + if (alpha === 0) + { + // Nothing to see, so abort early + return; + } + else if (renderer.currentAlpha !== alpha) + { + renderer.currentAlpha = alpha; + ctx.globalAlpha = alpha; + } + + // Blend Mode + if (renderer.currentBlendMode !== renderTexture.blendMode) { renderer.currentBlendMode = renderTexture.blendMode; ctx.globalCompositeOperation = renderer.blendModes[renderTexture.blendMode]; } - if (renderer.currentAlpha !== renderTexture.alpha) - { - renderer.currentAlpha = renderTexture.alpha; - ctx.globalAlpha = renderTexture.alpha; - } + // Scale Mode if (renderer.currentScaleMode !== renderTexture.scaleMode) { @@ -74,11 +87,14 @@ var RenderTextureCanvasRenderer = function (renderer, renderTexture, interpolati } ctx.save(); + if (parentMatrix !== undefined) { var matrix = parentMatrix.matrix; + ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); } + ctx.translate(renderTexture.x - camera.scrollX * renderTexture.scrollFactorX, renderTexture.y - camera.scrollY * renderTexture.scrollFactorY); ctx.rotate(renderTexture.rotation); ctx.scale(renderTexture.scaleX, renderTexture.scaleY); diff --git a/src/gameobjects/text/static/TextCanvasRenderer.js b/src/gameobjects/text/static/TextCanvasRenderer.js index 96fa8e70b..a6834ba1e 100644 --- a/src/gameobjects/text/static/TextCanvasRenderer.js +++ b/src/gameobjects/text/static/TextCanvasRenderer.js @@ -30,23 +30,31 @@ var TextCanvasRenderer = function (renderer, src, interpolationPercentage, camer var ctx = renderer.currentContext; - // var resolution = src.resolution; + // Alpha + var alpha = camera.alpha * src.alpha; + + if (alpha === 0) + { + // Nothing to see, so abort early + return; + } + else if (renderer.currentAlpha !== alpha) + { + renderer.currentAlpha = alpha; + ctx.globalAlpha = alpha; + } + // Blend Mode + if (renderer.currentBlendMode !== src.blendMode) { renderer.currentBlendMode = src.blendMode; ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; } - // Alpha - if (renderer.currentAlpha !== src.alpha) - { - renderer.currentAlpha = src.alpha; - ctx.globalAlpha = src.alpha; - } - // Smoothing + if (renderer.currentScaleMode !== src.scaleMode) { renderer.currentScaleMode = src.scaleMode; diff --git a/src/gameobjects/tilesprite/TileSpriteCanvasRenderer.js b/src/gameobjects/tilesprite/TileSpriteCanvasRenderer.js index 736e147c3..b25e88abb 100644 --- a/src/gameobjects/tilesprite/TileSpriteCanvasRenderer.js +++ b/src/gameobjects/tilesprite/TileSpriteCanvasRenderer.js @@ -33,6 +33,21 @@ var TileSpriteCanvasRenderer = function (renderer, src, interpolationPercentage, src.updateTileTexture(); + // Alpha + + var alpha = camera.alpha * src.alpha; + + if (alpha === 0) + { + // Nothing to see, so abort early + return; + } + else if (renderer.currentAlpha !== alpha) + { + renderer.currentAlpha = alpha; + ctx.globalAlpha = alpha; + } + // Blend Mode if (renderer.currentBlendMode !== src.blendMode) @@ -41,14 +56,6 @@ var TileSpriteCanvasRenderer = function (renderer, src, interpolationPercentage, ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; } - // Alpha - - if (renderer.currentAlpha !== src.alpha) - { - renderer.currentAlpha = src.alpha; - ctx.globalAlpha = src.alpha; - } - // Smoothing if (renderer.currentScaleMode !== src.scaleMode) diff --git a/src/renderer/canvas/CanvasRenderer.js b/src/renderer/canvas/CanvasRenderer.js index e997962eb..a15672c8f 100644 --- a/src/renderer/canvas/CanvasRenderer.js +++ b/src/renderer/canvas/CanvasRenderer.js @@ -395,11 +395,9 @@ var CanvasRenderer = new Class({ ctx.fillRect(camera.x, camera.y, camera.width, camera.height); } - if (this.currentAlpha !== 1) - { - ctx.globalAlpha = 1; - this.currentAlpha = 1; - } + ctx.globalAlpha = camera.alpha; + + this.currentAlpha = camera.alpha; if (this.currentBlendMode !== 0) { @@ -442,6 +440,7 @@ var CanvasRenderer = new Class({ ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.globalCompositeOperation = 'source-over'; + ctx.globalAlpha = 1; camera.flashEffect.postRenderCanvas(ctx); camera.fadeEffect.postRenderCanvas(ctx); diff --git a/src/renderer/canvas/utils/DrawImage.js b/src/renderer/canvas/utils/DrawImage.js index 660fa7eb2..2f0519882 100644 --- a/src/renderer/canvas/utils/DrawImage.js +++ b/src/renderer/canvas/utils/DrawImage.js @@ -22,6 +22,21 @@ var DrawImage = function (src, camera, parentMatrix) var frame = src.frame; var cd = frame.canvasData; + // Alpha + + var alpha = camera.alpha * src.alpha; + + if (alpha === 0) + { + // Nothing to see, so abort early + return; + } + else if (renderer.currentAlpha !== alpha) + { + renderer.currentAlpha = alpha; + ctx.globalAlpha = alpha; + } + // Blend Mode if (this.currentBlendMode !== src.blendMode) @@ -30,14 +45,6 @@ var DrawImage = function (src, camera, parentMatrix) ctx.globalCompositeOperation = this.blendModes[src.blendMode]; } - // Alpha - - if (this.currentAlpha !== src.alpha) - { - this.currentAlpha = src.alpha; - ctx.globalAlpha = src.alpha; - } - // Smoothing if (this.currentScaleMode !== src.scaleMode) From 237368161b9ffdacffda066fdd69676253b68c45 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Mon, 25 Jun 2018 16:31:54 +0100 Subject: [PATCH 20/48] Added Camera.setAlpha method --- src/cameras/2d/Camera.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/cameras/2d/Camera.js b/src/cameras/2d/Camera.js index d99a47564..e1cbb1db2 100644 --- a/src/cameras/2d/Camera.js +++ b/src/cameras/2d/Camera.js @@ -314,7 +314,9 @@ var Camera = new Class({ this.backgroundColor = ValueToColor('rgba(0,0,0,0)'); /** - * The Camera alpha value. + * The Camera alpha value. Setting this property impacts every single object that this Camera + * renders. You can either set the property directly, i.e. via a Tween, to fade a Camera in or out, + * or via the chainable `setAlpha` method instead. * * @name Phaser.Cameras.Scene2D.Camera#alpha * @type {number} @@ -510,6 +512,26 @@ var Camera = new Class({ this._follow = null; }, + /** + * Set the Alpha level of this Camera. The alpha controls the opacity of the Camera as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * + * @method Phaser.GameObjects.Components.Origin#setAlpha + * @since 3.11.0 + * + * @param {number} [value=1] - The Camera alpha value. + * + * @return {this} This Camera instance. + */ + setAlpha: function (value) + { + if (value === undefined) { value = 1; } + + this.alpha = value; + + return this; + }, + /** * Sets the rotation origin of this Camera. * From c6c9b25fdc1af9f16a9fc5dce9007def82db7c4e Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Mon, 25 Jun 2018 17:35:36 +0100 Subject: [PATCH 21/48] `Camera.alpha` (and its related method `Camera.setAlpha`) allows you to get an alpha level for the entire camera. This impacts everything it is rendering, even if those objects also have their own alpha values too. You can tween the property to make the camera contents fade in / out, or you can set it as needed in your game. --- CHANGELOG.md | 1 + src/renderer/canvas/utils/DrawImage.js | 7 ++-- .../webgl/pipelines/FlatTintPipeline.js | 2 +- .../webgl/pipelines/TextureTintPipeline.js | 32 +++++++++---------- .../DynamicTilemapLayerCanvasRenderer.js | 2 +- .../staticlayer/StaticTilemapLayer.js | 2 +- .../StaticTilemapLayerCanvasRenderer.js | 2 +- 7 files changed, 23 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e8039697b..4d5f8020c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Camera - New Features, Updates and Fixes +* `Camera.alpha` (and its related method `Camera.setAlpha`) allows you to get an alpha level for the entire camera. This impacts everything it is rendering, even if those objects also have their own alpha values too. You can tween the property to make the camera contents fade in / out, or you can set it as needed in your game. * `Camera.deadzone` (and its related method `Camera.setDeadzone`) allows you to specify the deadzone for a camera. The deadzone is a rectangular region used when a camera is following a target. If the target is within the deadzone then the camera will not scroll. As soon as the target leaves the deadzone, the camera will begin tracking it (applying lerp if needed.) It allows you to set a region of the camera in which a player can move freely before tracking begins. The deadzone is re-centered on the camera mid point every frame, meaning you can also use the rectangle for other in-game chcecks as needed. * `Camera.midPoint` is a new Vec2 property that is updated every frame. Use it to obtain exactly where in the world the center of the camera is currently looking. * `Camera.displayWidth` is a new property that returns the display width of the camera, factoring in the current zoom level. diff --git a/src/renderer/canvas/utils/DrawImage.js b/src/renderer/canvas/utils/DrawImage.js index 2f0519882..cd87407f9 100644 --- a/src/renderer/canvas/utils/DrawImage.js +++ b/src/renderer/canvas/utils/DrawImage.js @@ -31,11 +31,8 @@ var DrawImage = function (src, camera, parentMatrix) // Nothing to see, so abort early return; } - else if (renderer.currentAlpha !== alpha) - { - renderer.currentAlpha = alpha; - ctx.globalAlpha = alpha; - } + + ctx.globalAlpha = alpha; // Blend Mode diff --git a/src/renderer/webgl/pipelines/FlatTintPipeline.js b/src/renderer/webgl/pipelines/FlatTintPipeline.js index 0c50e4b44..9857eff47 100644 --- a/src/renderer/webgl/pipelines/FlatTintPipeline.js +++ b/src/renderer/webgl/pipelines/FlatTintPipeline.js @@ -732,7 +732,7 @@ var FlatTintPipeline = new Class({ var srcScaleY = graphics.scaleY; var srcRotation = graphics.rotation; var commands = graphics.commandBuffer; - var alpha = graphics.alpha; + var alpha = camera.alpha * graphics.alpha; var lineAlpha = 1.0; var fillAlpha = 1.0; var lineColor = 0; diff --git a/src/renderer/webgl/pipelines/TextureTintPipeline.js b/src/renderer/webgl/pipelines/TextureTintPipeline.js index 2e2ec95b8..ed44c25f4 100644 --- a/src/renderer/webgl/pipelines/TextureTintPipeline.js +++ b/src/renderer/webgl/pipelines/TextureTintPipeline.js @@ -813,10 +813,10 @@ var TextureTintPipeline = new Class({ var scaleX = sprite.scaleX; var scaleY = sprite.scaleY; var rotation = sprite.rotation; - var alphaTL = sprite._alphaTL; - var alphaTR = sprite._alphaTR; - var alphaBL = sprite._alphaBL; - var alphaBR = sprite._alphaBR; + var alphaTL = camera.alpha * sprite._alphaTL; + var alphaTR = camera.alpha * sprite._alphaTR; + var alphaBL = camera.alpha * sprite._alphaBL; + var alphaBR = camera.alpha * sprite._alphaBR; var tintTL = sprite._tintTL; var tintTR = sprite._tintTR; var tintBL = sprite._tintBL; @@ -1062,7 +1062,7 @@ var TextureTintPipeline = new Class({ vertexViewF32[vertexOffset + 1] = ty; vertexViewF32[vertexOffset + 2] = uvs[index + 0]; vertexViewF32[vertexOffset + 3] = uvs[index + 1]; - vertexViewU32[vertexOffset + 4] = getTint(colors[index0], alphas[index0]); + vertexViewU32[vertexOffset + 4] = getTint(colors[index0], camera.alpha * alphas[index0]); vertexOffset += 5; index0 += 1; @@ -1116,7 +1116,7 @@ var TextureTintPipeline = new Class({ var lineHeight = fontData.lineHeight; var scale = (bitmapText.fontSize / fontData.size); var chars = fontData.chars; - var alpha = bitmapText.alpha; + var alpha = camera.alpha * bitmapText.alpha; var vTintTL = getTint(bitmapText._tintTL, alpha); var vTintTR = getTint(bitmapText._tintTR, alpha); var vTintBL = getTint(bitmapText._tintBL, alpha); @@ -1393,7 +1393,7 @@ var TextureTintPipeline = new Class({ var lineHeight = fontData.lineHeight; var scale = (bitmapText.fontSize / fontData.size); var chars = fontData.chars; - var alpha = bitmapText.alpha; + var alpha = camera.alpha * bitmapText.alpha; var vTintTL = getTint(bitmapText._tintTL, alpha); var vTintTR = getTint(bitmapText._tintTR, alpha); var vTintBL = getTint(bitmapText._tintBL, alpha); @@ -1724,10 +1724,10 @@ var TextureTintPipeline = new Class({ text.scrollFactorX, text.scrollFactorY, text.displayOriginX, text.displayOriginY, 0, 0, text.canvasTexture.width, text.canvasTexture.height, - getTint(text._tintTL, text._alphaTL), - getTint(text._tintTR, text._alphaTR), - getTint(text._tintBL, text._alphaBL), - getTint(text._tintBR, text._alphaBR), + getTint(text._tintTL, camera.alpha * text._alphaTL), + getTint(text._tintTR, camera.alpha * text._alphaTR), + getTint(text._tintBL, camera.alpha * text._alphaBL), + getTint(text._tintBR, camera.alpha * text._alphaBR), 0, 0, camera, parentTransformMatrix @@ -1752,7 +1752,7 @@ var TextureTintPipeline = new Class({ var tileset = tilemapLayer.tileset; var scrollFactorX = tilemapLayer.scrollFactorX; var scrollFactorY = tilemapLayer.scrollFactorY; - var alpha = tilemapLayer.alpha; + var alpha = camera.alpha * tilemapLayer.alpha; var x = tilemapLayer.x; var y = tilemapLayer.y; var sx = tilemapLayer.scaleX; @@ -1818,10 +1818,10 @@ var TextureTintPipeline = new Class({ tileSprite.scrollFactorX, tileSprite.scrollFactorY, tileSprite.originX * tileSprite.width, tileSprite.originY * tileSprite.height, 0, 0, tileSprite.width, tileSprite.height, - getTint(tileSprite._tintTL, tileSprite._alphaTL), - getTint(tileSprite._tintTR, tileSprite._alphaTR), - getTint(tileSprite._tintBL, tileSprite._alphaBL), - getTint(tileSprite._tintBR, tileSprite._alphaBR), + getTint(tileSprite._tintTL, camera.alpha * tileSprite._alphaTL), + getTint(tileSprite._tintTR, camera.alpha * tileSprite._alphaTR), + getTint(tileSprite._tintBL, camera.alpha * tileSprite._alphaBL), + getTint(tileSprite._tintBR, camera.alpha * tileSprite._alphaBR), (tileSprite.tilePositionX % tileSprite.frame.width) / tileSprite.frame.width, (tileSprite.tilePositionY % tileSprite.frame.height) / tileSprite.frame.height, camera, diff --git a/src/tilemaps/dynamiclayer/DynamicTilemapLayerCanvasRenderer.js b/src/tilemaps/dynamiclayer/DynamicTilemapLayerCanvasRenderer.js index 50f73f893..ab9b5af13 100644 --- a/src/tilemaps/dynamiclayer/DynamicTilemapLayerCanvasRenderer.js +++ b/src/tilemaps/dynamiclayer/DynamicTilemapLayerCanvasRenderer.js @@ -67,7 +67,7 @@ var DynamicTilemapLayerCanvasRenderer = function (renderer, src, interpolationPe ctx.scale(tile.flipX ? -1 : 1, tile.flipY ? -1 : 1); } - ctx.globalAlpha = src.alpha * tile.alpha; + ctx.globalAlpha = camera.alpha * src.alpha * tile.alpha; ctx.drawImage( image, diff --git a/src/tilemaps/staticlayer/StaticTilemapLayer.js b/src/tilemaps/staticlayer/StaticTilemapLayer.js index f3d3471d2..0fc087ab4 100644 --- a/src/tilemaps/staticlayer/StaticTilemapLayer.js +++ b/src/tilemaps/staticlayer/StaticTilemapLayer.js @@ -281,7 +281,7 @@ var StaticTilemapLayer = new Class({ var ty2 = tyh; var tx3 = txw; var ty3 = ty; - var tint = Utils.getTintAppendFloatAlpha(0xffffff, this.alpha * tile.alpha); + var tint = Utils.getTintAppendFloatAlpha(0xffffff, camera.alpha * this.alpha * tile.alpha); vertexViewF32[voffset + 0] = tx0; vertexViewF32[voffset + 1] = ty0; diff --git a/src/tilemaps/staticlayer/StaticTilemapLayerCanvasRenderer.js b/src/tilemaps/staticlayer/StaticTilemapLayerCanvasRenderer.js index a881f5065..c838170f5 100644 --- a/src/tilemaps/staticlayer/StaticTilemapLayerCanvasRenderer.js +++ b/src/tilemaps/staticlayer/StaticTilemapLayerCanvasRenderer.js @@ -42,7 +42,7 @@ var StaticTilemapLayerCanvasRenderer = function (renderer, src, interpolationPer ctx.rotate(src.rotation); ctx.scale(src.scaleX, src.scaleY); ctx.scale(src.flipX ? -1 : 1, src.flipY ? -1 : 1); - ctx.globalAlpha = src.alpha; + ctx.globalAlpha = camera.alpha * src.alpha; for (var index = 0; index < tileCount; ++index) { From bb7b99a4dbfacd9d6cf3822a1152bbe2471b6515 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Mon, 25 Jun 2018 22:53:42 +0100 Subject: [PATCH 22/48] Updated log and formatting --- CHANGELOG.md | 5 ++++- src/renderer/webgl/pipelines/TextureTintPipeline.js | 10 +++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d5f8020c..06b13b28c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ ### Camera - New Features, Updates and Fixes -* `Camera.alpha` (and its related method `Camera.setAlpha`) allows you to get an alpha level for the entire camera. This impacts everything it is rendering, even if those objects also have their own alpha values too. You can tween the property to make the camera contents fade in / out, or you can set it as needed in your game. +* `Camera.alpha` (and its related method `Camera.setAlpha`) allows you to set an alpha level for the entire camera. This impacts everything it is rendering, even if those objects also have their own alpha values too. You can tween the property to make the camera contents fade in / out, or otherwise set it as needed in your game. * `Camera.deadzone` (and its related method `Camera.setDeadzone`) allows you to specify the deadzone for a camera. The deadzone is a rectangular region used when a camera is following a target. If the target is within the deadzone then the camera will not scroll. As soon as the target leaves the deadzone, the camera will begin tracking it (applying lerp if needed.) It allows you to set a region of the camera in which a player can move freely before tracking begins. The deadzone is re-centered on the camera mid point every frame, meaning you can also use the rectangle for other in-game chcecks as needed. * `Camera.midPoint` is a new Vec2 property that is updated every frame. Use it to obtain exactly where in the world the center of the camera is currently looking. * `Camera.displayWidth` is a new property that returns the display width of the camera, factoring in the current zoom level. @@ -24,6 +24,7 @@ * `Graphics.fillRoundedRect` will draw a stroked rounded rectangle to a Graphics object. The radius of the corners can be either a number, or an object, allowing you to specify different radius per corner (thanks @TadejZupancic) * `Graphics.strokeRoundedRect` will draw a filled rounded rectangle to a Graphics object. The radius of the corners can be either a number, or an object, allowing you to specify different radius per corner (thanks @TadejZupancic) +* `ParticleEmitter.stop` is a new chainable method to stop a particle emitter. It's the same as setting `on` to `false` but means you don't have to break the method flow to do so (thanks @samme) ### Updates @@ -44,6 +45,8 @@ * Although the Blitter object had the Alpha component, setting it made no difference. Setting Blitter alpha now impacts the rendering of all children, in both Canvas and WebGL, and you can also specify an alpha per Bob as well. * `Camera.centerToBounds` didn't take the bounds offset into account, so bounds at non-zero positions wouldn't center properly. All bounds now center correctly. Fix #3706 (thanks @cyantree) * `SceneManager.run` would ignore scenes that are currently in the queue of scenes pending to be added. This has now been fixed so that the scene is queued to be started once it's ready (thanks @rook2pawn) +* `GameObject.disableInteractive` was toggling input. Every second call would turn the input back on (thanks @TadejZupancic) +* The position of the TilemapLayer wasn't taken into account when culling tiles for the Camera. It's now calculated as part of the cull flow (thanks @Upperfoot) ### Examples, Documentation and TypeScript diff --git a/src/renderer/webgl/pipelines/TextureTintPipeline.js b/src/renderer/webgl/pipelines/TextureTintPipeline.js index ed44c25f4..33f290aa3 100644 --- a/src/renderer/webgl/pipelines/TextureTintPipeline.js +++ b/src/renderer/webgl/pipelines/TextureTintPipeline.js @@ -502,18 +502,21 @@ var TextureTintPipeline = new Class({ var yh = y + frame.height; var sr = sin(particle.rotation); var cr = cos(particle.rotation); + var sra = cr * particle.scaleX; var srb = sr * particle.scaleX; var src = -sr * particle.scaleY; var srd = cr * particle.scaleY; var sre = particle.x - scrollX; var srf = particle.y - scrollY; + var mva = sra * cma + srb * cmc; var mvb = sra * cmb + srb * cmd; var mvc = src * cma + srd * cmc; var mvd = src * cmb + srd * cmd; var mve = sre * cma + srf * cmc + cme; var mvf = sre * cmb + srf * cmd + cmf; + var tx0 = x * mva + y * mvc + mve; var ty0 = x * mvb + y * mvd + mvf; var tx1 = x * mva + yh * mvc + mve; @@ -522,6 +525,7 @@ var TextureTintPipeline = new Class({ var ty2 = xw * mvb + yh * mvd + mvf; var tx3 = xw * mva + y * mvc + mve; var ty3 = xw * mvb + y * mvd + mvf; + var vertexOffset = this.vertexCount * vertexComponentCount; if (roundPixels) @@ -541,26 +545,31 @@ var TextureTintPipeline = new Class({ vertexViewF32[vertexOffset + 2] = uvs.x0; vertexViewF32[vertexOffset + 3] = uvs.y0; vertexViewU32[vertexOffset + 4] = color; + vertexViewF32[vertexOffset + 5] = tx1; vertexViewF32[vertexOffset + 6] = ty1; vertexViewF32[vertexOffset + 7] = uvs.x1; vertexViewF32[vertexOffset + 8] = uvs.y1; vertexViewU32[vertexOffset + 9] = color; + vertexViewF32[vertexOffset + 10] = tx2; vertexViewF32[vertexOffset + 11] = ty2; vertexViewF32[vertexOffset + 12] = uvs.x2; vertexViewF32[vertexOffset + 13] = uvs.y2; vertexViewU32[vertexOffset + 14] = color; + vertexViewF32[vertexOffset + 15] = tx0; vertexViewF32[vertexOffset + 16] = ty0; vertexViewF32[vertexOffset + 17] = uvs.x0; vertexViewF32[vertexOffset + 18] = uvs.y0; vertexViewU32[vertexOffset + 19] = color; + vertexViewF32[vertexOffset + 20] = tx2; vertexViewF32[vertexOffset + 21] = ty2; vertexViewF32[vertexOffset + 22] = uvs.x2; vertexViewF32[vertexOffset + 23] = uvs.y2; vertexViewU32[vertexOffset + 24] = color; + vertexViewF32[vertexOffset + 25] = tx3; vertexViewF32[vertexOffset + 26] = ty3; vertexViewF32[vertexOffset + 27] = uvs.x3; @@ -574,7 +583,6 @@ var TextureTintPipeline = new Class({ this.flush(); this.setTexture2D(texture, 0); } - } particleOffset += batchSize; From b95f98002389143e813286021a1e27d81f1b5a2d Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Tue, 26 Jun 2018 16:08:14 +0100 Subject: [PATCH 23/48] Added in data object passing to all relevant methods #3748 --- CHANGELOG.md | 6 ++++++ src/scene/SceneManager.js | 20 ++++++++++++-------- src/scene/ScenePlugin.js | 39 ++++++++++++++++++++++----------------- src/scene/Systems.js | 32 ++++++++++++++++++++------------ 4 files changed, 60 insertions(+), 37 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 06b13b28c..837069428 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,11 @@ * `Graphics.fillRoundedRect` will draw a stroked rounded rectangle to a Graphics object. The radius of the corners can be either a number, or an object, allowing you to specify different radius per corner (thanks @TadejZupancic) * `Graphics.strokeRoundedRect` will draw a filled rounded rectangle to a Graphics object. The radius of the corners can be either a number, or an object, allowing you to specify different radius per corner (thanks @TadejZupancic) * `ParticleEmitter.stop` is a new chainable method to stop a particle emitter. It's the same as setting `on` to `false` but means you don't have to break the method flow to do so (thanks @samme) +* `ScenePlugin.pause` (and the corresponding methods in Scene Systems and the Scene Manager) now has a new optional `data` argument, which is passed to the target Scene and emitted in its 'pause' event. +* `ScenePlugin.resume` (and the corresponding methods in Scene Systems and the Scene Manager) now has a new optional `data` argument, which is passed to the target Scene and emitted in its 'resume' event. +* `ScenePlugin.sleep` (and the corresponding methods in Scene Systems and the Scene Manager) now has a new optional `data` argument, which is passed to the target Scene and emitted in its 'sleep' event. +* `ScenePlugin.wake` (and the corresponding methods in Scene Systems and the Scene Manager) now has a new optional `data` argument, which is passed to the target Scene and emitted in its 'wake' event. +* `ScenePlugin.setActive` now has a new optional `data` argument, which is passed to the target Scene and emitted in its 'pause' or 'resume' events. ### Updates @@ -33,6 +38,7 @@ * If a Game Object is already being dragged, it cannot be dragged by another pointer (in multi-touch mode) until the original pointer has released it (thanks @rexrainbow) * Calling `Tween.play` on a tween created via `TweenManager.create` wouldn't actually start playback until the tween was first added to the Tween Manager. Now, calling `play` will have it automatically add itself to the Tween Manager if it's not already in there. Fix #3763 (thanks @pantoninho) * If the Blitter object has no Bob's to render it will now abort immediately, avoiding several context calls in Canvas mode. +* `Scene.run` will now pass the optional `data` object in all cases, no matter if it's waking, resuming or starting a Scene (thanks @rook2pawn) ### Bug Fixes diff --git a/src/scene/SceneManager.js b/src/scene/SceneManager.js index c1a9d598a..22018e19a 100644 --- a/src/scene/SceneManager.js +++ b/src/scene/SceneManager.js @@ -928,16 +928,17 @@ var SceneManager = new Class({ * @since 3.0.0 * * @param {string} key - The Scene to pause. + * @param {object} [data] - An optional data object that will be passed to the Scene and emitted by its pause event. * * @return {Phaser.Scenes.SceneManager} This SceneManager. */ - pause: function (key) + pause: function (key, data) { var scene = this.getScene(key); if (scene) { - scene.sys.pause(); + scene.sys.pause(data); } return this; @@ -950,16 +951,17 @@ var SceneManager = new Class({ * @since 3.0.0 * * @param {string} key - The Scene to resume. + * @param {object} [data] - An optional data object that will be passed to the Scene and emitted by its resume event. * * @return {Phaser.Scenes.SceneManager} This SceneManager. */ - resume: function (key) + resume: function (key, data) { var scene = this.getScene(key); if (scene) { - scene.sys.resume(); + scene.sys.resume(data); } return this; @@ -972,16 +974,17 @@ var SceneManager = new Class({ * @since 3.0.0 * * @param {string} key - The Scene to put to sleep. + * @param {object} [data] - An optional data object that will be passed to the Scene and emitted by its sleep event. * * @return {Phaser.Scenes.SceneManager} This SceneManager. */ - sleep: function (key) + sleep: function (key, data) { var scene = this.getScene(key); if (scene && !scene.sys.isTransitioning()) { - scene.sys.sleep(); + scene.sys.sleep(data); } return this; @@ -994,16 +997,17 @@ var SceneManager = new Class({ * @since 3.0.0 * * @param {string} key - The Scene to wake up. + * @param {object} [data] - An optional data object that will be passed to the Scene and emitted by its wake event. * * @return {Phaser.Scenes.SceneManager} This SceneManager. */ - wake: function (key) + wake: function (key, data) { var scene = this.getScene(key); if (scene) { - scene.sys.wake(); + scene.sys.wake(data); } return this; diff --git a/src/scene/ScenePlugin.js b/src/scene/ScenePlugin.js index 2c74110a5..67c682b55 100644 --- a/src/scene/ScenePlugin.js +++ b/src/scene/ScenePlugin.js @@ -191,7 +191,7 @@ var ScenePlugin = new Class({ * @method Phaser.Scenes.ScenePlugin#start * @since 3.0.0 * - * @param {string} key - The Scene to start. + * @param {string} [key] - The Scene to start. * @param {object} [data] - The Scene data. * * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. @@ -511,7 +511,7 @@ var ScenePlugin = new Class({ * @since 3.10.0 * * @param {string} key - The Scene to run. - * @param {object} [data] - A data object that will be passed to the Scene that is run _only if the Scene isn't asleep or paused_. + * @param {object} [data] - A data object that will be passed to the Scene and emitted in its ready, wake, or resume events. * * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. */ @@ -535,15 +535,16 @@ var ScenePlugin = new Class({ * @method Phaser.Scenes.ScenePlugin#pause * @since 3.0.0 * - * @param {string} key - The Scene to pause. + * @param {string} [key] - The Scene to pause. + * @param {object} [data] - An optional data object that will be passed to the Scene and emitted in its pause event. * * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. */ - pause: function (key) + pause: function (key, data) { if (key === undefined) { key = this.key; } - this.manager.pause(key); + this.manager.pause(key, data); return this; }, @@ -554,15 +555,16 @@ var ScenePlugin = new Class({ * @method Phaser.Scenes.ScenePlugin#resume * @since 3.0.0 * - * @param {string} key - The Scene to resume. + * @param {string} [key] - The Scene to resume. + * @param {object} [data] - An optional data object that will be passed to the Scene and emitted in its resume event. * * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. */ - resume: function (key) + resume: function (key, data) { if (key === undefined) { key = this.key; } - this.manager.resume(key); + this.manager.resume(key, data); return this; }, @@ -573,15 +575,16 @@ var ScenePlugin = new Class({ * @method Phaser.Scenes.ScenePlugin#sleep * @since 3.0.0 * - * @param {string} key - The Scene to put to sleep. + * @param {string} [key] - The Scene to put to sleep. + * @param {object} [data] - An optional data object that will be passed to the Scene and emitted in its sleep event. * * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. */ - sleep: function (key) + sleep: function (key, data) { if (key === undefined) { key = this.key; } - this.manager.sleep(key); + this.manager.sleep(key, data); return this; }, @@ -593,14 +596,15 @@ var ScenePlugin = new Class({ * @since 3.0.0 * * @param {string} key - The Scene to wake up. + * @param {object} [data] - An optional data object that will be passed to the Scene and emitted in its wake event. * * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. */ - wake: function (key) + wake: function (key, data) { if (key === undefined) { key = this.key; } - this.manager.wake(key); + this.manager.wake(key, data); return this; }, @@ -657,12 +661,13 @@ var ScenePlugin = new Class({ * @method Phaser.Scenes.ScenePlugin#setActive * @since 3.0.0 * - * @param {boolean} value - The active value. - * @param {string} [key] - The Scene to set the active state for. + * @param {boolean} value - If `true` the Scene will be resumed. If `false` it will be paused. + * @param {string} [key] - The Scene to set the active state of. + * @param {object} [data] - An optional data object that will be passed to the Scene and emitted with its events. * * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. */ - setActive: function (value, key) + setActive: function (value, key, data) { if (key === undefined) { key = this.key; } @@ -670,7 +675,7 @@ var ScenePlugin = new Class({ if (scene) { - scene.sys.setActive(value); + scene.sys.setActive(value, data); } return this; diff --git a/src/scene/Systems.js b/src/scene/Systems.js index 0c775c304..512293b22 100644 --- a/src/scene/Systems.js +++ b/src/scene/Systems.js @@ -345,10 +345,12 @@ var Systems = new Class({ * * @method Phaser.Scenes.Systems#pause * @since 3.0.0 + * + * @param {object} [data] - A data object that will be passed in the 'pause' event. * * @return {Phaser.Scenes.Systems} This Systems object. */ - pause: function () + pause: function (data) { if (this.settings.active) { @@ -356,7 +358,7 @@ var Systems = new Class({ this.settings.active = false; - this.events.emit('pause', this); + this.events.emit('pause', this, data); } return this; @@ -368,7 +370,7 @@ var Systems = new Class({ * @method Phaser.Scenes.Systems#resume * @since 3.0.0 * - * @param {object} [data] - A data object that will be passed on the 'resume' event. + * @param {object} [data] - A data object that will be passed in the 'resume' event. * * @return {Phaser.Scenes.Systems} This Systems object. */ @@ -396,17 +398,19 @@ var Systems = new Class({ * * @method Phaser.Scenes.Systems#sleep * @since 3.0.0 + * + * @param {object} [data] - A data object that will be passed in the 'sleep' event. * * @return {Phaser.Scenes.Systems} This Systems object. */ - sleep: function () + sleep: function (data) { this.settings.status = CONST.SLEEPING; this.settings.active = false; this.settings.visible = false; - this.events.emit('sleep', this); + this.events.emit('sleep', this, data); return this; }, @@ -417,7 +421,7 @@ var Systems = new Class({ * @method Phaser.Scenes.Systems#wake * @since 3.0.0 * - * @param {object} [data] - A data object that will be passed on the 'wake' event. + * @param {object} [data] - A data object that will be passed in the 'wake' event. * * @return {Phaser.Scenes.Systems} This Systems object. */ @@ -538,24 +542,26 @@ var Systems = new Class({ /** * Set the active state of this Scene. + * * An active Scene will run its core update loop. * * @method Phaser.Scenes.Systems#setActive * @since 3.0.0 * * @param {boolean} value - If `true` the Scene will be resumed, if previously paused. If `false` it will be paused. + * @param {object} [data] - A data object that will be passed in the 'resume' or 'pause' events. * * @return {Phaser.Scenes.Systems} This Systems object. */ - setActive: function (value) + setActive: function (value, data) { if (value) { - return this.resume(); + return this.resume(data); } else { - return this.pause(); + return this.pause(data); } }, @@ -584,7 +590,7 @@ var Systems = new Class({ this.events.emit('start', this); // For user-land code to listen out for - this.events.emit('ready', this); + this.events.emit('ready', this, data); }, /** @@ -611,8 +617,10 @@ var Systems = new Class({ * * @method Phaser.Scenes.Systems#shutdown * @since 3.0.0 + * + * @param {object} [data] - A data object that will be passed in the 'shutdown' event. */ - shutdown: function () + shutdown: function (data) { this.events.off('transitioninit'); this.events.off('transitionstart'); @@ -624,7 +632,7 @@ var Systems = new Class({ this.settings.active = false; this.settings.visible = false; - this.events.emit('shutdown', this); + this.events.emit('shutdown', this, data); }, /** From f1190529d23d951a244ab6fb424d9c4126beabfd Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Tue, 26 Jun 2018 16:35:45 +0100 Subject: [PATCH 24/48] `ScenePlugin.start` and `ScenePlugin.restart` will now always queue the op with the Scene Manager, regardless of the state of the Scene, in order to avoid issues where plugins carry on running for a frame before closing down. Fix #3776 --- CHANGELOG.md | 1 + src/scene/SceneManager.js | 7 +++---- src/scene/ScenePlugin.js | 24 ++++-------------------- 3 files changed, 8 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 837069428..de1bb0ed8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ * Calling `Tween.play` on a tween created via `TweenManager.create` wouldn't actually start playback until the tween was first added to the Tween Manager. Now, calling `play` will have it automatically add itself to the Tween Manager if it's not already in there. Fix #3763 (thanks @pantoninho) * If the Blitter object has no Bob's to render it will now abort immediately, avoiding several context calls in Canvas mode. * `Scene.run` will now pass the optional `data` object in all cases, no matter if it's waking, resuming or starting a Scene (thanks @rook2pawn) +* `ScenePlugin.start` and `ScenePlugin.restart` will now always queue the op with the Scene Manager, regardless of the state of the Scene, in order to avoid issues where plugins carry on running for a frame before closing down. Fix #3776 (thanks @jjalonso) ### Bug Fixes diff --git a/src/scene/SceneManager.js b/src/scene/SceneManager.js index 22018e19a..15afce399 100644 --- a/src/scene/SceneManager.js +++ b/src/scene/SceneManager.js @@ -441,6 +441,8 @@ var SceneManager = new Class({ { scene.init.call(scene, settings.data); + settings.status = CONST.INIT; + if (settings.isTransition) { sys.events.emit('transitioninit', settings.transitionFrom, settings.transitionDuration); @@ -623,10 +625,7 @@ var SceneManager = new Class({ sys.sceneUpdate = scene.update; } - if (settings.status === CONST.CREATING) - { - settings.status = CONST.RUNNING; - } + settings.status = CONST.RUNNING; }, /** diff --git a/src/scene/ScenePlugin.js b/src/scene/ScenePlugin.js index 67c682b55..5597dbc2b 100644 --- a/src/scene/ScenePlugin.js +++ b/src/scene/ScenePlugin.js @@ -200,16 +200,8 @@ var ScenePlugin = new Class({ { if (key === undefined) { key = this.key; } - if (this.settings.status !== CONST.RUNNING) - { - this.manager.queueOp('stop', this.key); - this.manager.queueOp('start', key, data); - } - else - { - this.manager.stop(this.key); - this.manager.start(key, data); - } + this.manager.queueOp('stop', this.key); + this.manager.queueOp('start', key, data); return this; }, @@ -228,16 +220,8 @@ var ScenePlugin = new Class({ { var key = this.key; - if (this.settings.status !== CONST.RUNNING) - { - this.manager.queueOp('stop', key); - this.manager.queueOp('start', key, data); - } - else - { - this.manager.stop(key); - this.manager.start(key, data); - } + this.manager.queueOp('stop', key); + this.manager.queueOp('start', key, data); return this; }, From ba9890e9f16c1032f11789031ceded01c5f505a5 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Tue, 26 Jun 2018 16:41:37 +0100 Subject: [PATCH 25/48] lint fix --- src/cameras/2d/CameraManager.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cameras/2d/CameraManager.js b/src/cameras/2d/CameraManager.js index a1170a96d..c5c8313cc 100644 --- a/src/cameras/2d/CameraManager.js +++ b/src/cameras/2d/CameraManager.js @@ -703,6 +703,7 @@ var CameraManager = new Class({ } }, + /** * A reference to Camera 10 in the Camera Manager. * From c2fbad835609e042e649298e0739c38d8bb05363 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Tue, 26 Jun 2018 17:24:51 +0100 Subject: [PATCH 26/48] Added jsdocs. Now 100% complete! --- CHANGELOG.md | 3 + src/cameras/2d/CameraManager.js | 153 ++++++++++++++++++++++---------- 2 files changed, 110 insertions(+), 46 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index de1bb0ed8..356b6f9eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,11 @@ ### Camera - New Features, Updates and Fixes +* All of the 2D Camera classes are now 100% covered by JSDocs! * `Camera.alpha` (and its related method `Camera.setAlpha`) allows you to set an alpha level for the entire camera. This impacts everything it is rendering, even if those objects also have their own alpha values too. You can tween the property to make the camera contents fade in / out, or otherwise set it as needed in your game. * `Camera.deadzone` (and its related method `Camera.setDeadzone`) allows you to specify the deadzone for a camera. The deadzone is a rectangular region used when a camera is following a target. If the target is within the deadzone then the camera will not scroll. As soon as the target leaves the deadzone, the camera will begin tracking it (applying lerp if needed.) It allows you to set a region of the camera in which a player can move freely before tracking begins. The deadzone is re-centered on the camera mid point every frame, meaning you can also use the rectangle for other in-game chcecks as needed. +* `Camera.pan` is a new Camera Effect that allows you to control automatic camera pans between points in your game world. You can specify a duration and ease type for the pan, and it'll emit events just like all other camera effects, so you can hook into the start, update and completion of the pan. See the examples and docs for more details. +* `Camera.zoom` is a new Camera Effect that allows you to control automatic camera zooming. You can specify a duration and ease type for the zoom, as well as the zoom factor of course, and it'll emit events just like all other camera effects, so you can hook into the start, update and completion of the zoom. Used in combination with the new Pan effect you can zoom and pan around with ease. See the examples and docs for more details. * `Camera.midPoint` is a new Vec2 property that is updated every frame. Use it to obtain exactly where in the world the center of the camera is currently looking. * `Camera.displayWidth` is a new property that returns the display width of the camera, factoring in the current zoom level. * `Camera.displayHeight` is a new property that returns the display height of the camera, factoring in the current zoom level. diff --git a/src/cameras/2d/CameraManager.js b/src/cameras/2d/CameraManager.js index c5c8313cc..fbe2cda31 100644 --- a/src/cameras/2d/CameraManager.js +++ b/src/cameras/2d/CameraManager.js @@ -13,30 +13,54 @@ var RectangleContains = require('../../geom/rectangle/Contains'); /** * @typedef {object} InputJSONCameraObject * - * @property {string} [name=''] - [description] - * @property {integer} [x=0] - [description] - * @property {integer} [y=0] - [description] - * @property {integer} [width] - [description] - * @property {integer} [height] - [description] - * @property {float} [zoom=1] - [description] - * @property {float} [rotation=0] - [description] - * @property {boolean} [roundPixels=false] - [description] - * @property {float} [scrollX=0] - [description] - * @property {float} [scrollY=0] - [description] - * @property {(false|string)} [backgroundColor=false] - [description] - * @property {?object} [bounds] - [description] - * @property {number} [bounds.x=0] - [description] - * @property {number} [bounds.y=0] - [description] - * @property {number} [bounds.width] - [description] - * @property {number} [bounds.height] - [description] + * @property {string} [name=''] - The name of the Camera. + * @property {integer} [x=0] - The horizontal position of the Camera viewport. + * @property {integer} [y=0] - The vertical position of the Camera viewport. + * @property {integer} [width] - The width of the Camera viewport. + * @property {integer} [height] - The height of the Camera viewport. + * @property {float} [zoom=1] - The default zoom level of the Camera. + * @property {float} [rotation=0] - The rotation of the Camera, in radians. + * @property {boolean} [roundPixels=false] - Should the Camera round pixels before rendering? + * @property {float} [scrollX=0] - The horizontal scroll position of the Camera. + * @property {float} [scrollY=0] - The vertical scroll position of the Camera. + * @property {(false|string)} [backgroundColor=false] - A CSS color string controlling the Camera background color. + * @property {?object} [bounds] - Defines the Camera bounds. + * @property {number} [bounds.x=0] - The top-left extent of the Camera bounds. + * @property {number} [bounds.y=0] - The top-left extent of the Camera bounds. + * @property {number} [bounds.width] - The width of the Camera bounds. + * @property {number} [bounds.height] - The height of the Camera bounds. */ -// TODO stop it assigning more than 32 cameras (or whatever the limit is) -// The remove method leaves gaps in the ID list - /** * @classdesc - * [description] + * The Camera Manager is a plugin that belongs to a Scene and is responsible for managing all of the Scene Cameras. + * + * By default you can access the Camera Manager from within a Scene using `this.cameras`, although this can be changed + * in your game config. + * + * The Camera Manager can manage up to 31 unique Cameras. You can use the properties `camera1` through to `camera10` + * for quick and easy access to the first 10 cameras you define. + * + * Create new Cameras using the `add` method. Or extend the Camera class with your own addition code and then add + * the new Camera in using the `addExisting` method. + * + * Cameras provide a view into your game world, and can be positioned, rotated, zoomed and scrolled accordingly. + * + * A Camera consists of two elements: The viewport and the scroll values. + * + * The viewport is the physical position and size of the Camera within your game. Cameras, by default, are + * created the same size as your game, but their position and size can be set to anything. This means if you + * wanted to create a camera that was 320x200 in size, positioned in the bottom-right corner of your game, + * you'd adjust the viewport to do that (using methods like `setViewport` and `setSize`). + * + * If you wish to change where the Camera is looking in your game, then you scroll it. You can do this + * via the properties `scrollX` and `scrollY` or the method `setScroll`. Scrolling has no impact on the + * viewport, and changing the viewport has no impact on the scrolling. + * + * By default a Camera will render all Game Objects it can see. You can change this using the `ignore` method, + * allowing you to filter Game Objects out on a per-Camera basis. + * + * A Camera also has built-in special effects including Fade, Flash and Camera Shake. * * @class CameraManager * @memberOf Phaser.Cameras.Scene2D @@ -174,19 +198,30 @@ var CameraManager = new Class({ }, /** - * [description] + * Adds a new Camera into the Camera Manager. The Camera Manager can support up to 31 different Cameras. + * + * Each Camera has its own viewport, which controls the size of the Camera and its position within the canvas. + * + * Use the `Camera.scrollX` and `Camera.scrollY` properties to change where the Camera is looking, or the + * Camera methods such as `centerOn`. Cameras also have built in special effects, such as fade, flash, shake, + * pan and zoom. + * + * By default Cameras are transparent and will render anything that they can see based on their `scrollX` + * and `scrollY` values. Game Objects can be set to be ignored by a Camera by using the `Camera.ignore` method. + * + * See the Camera class documentation for more details. * * @method Phaser.Cameras.Scene2D.CameraManager#add * @since 3.0.0 * - * @param {number} [x=0] - [description] - * @param {number} [y=0] - [description] - * @param {number} [width] - [description] - * @param {number} [height] - [description] - * @param {boolean} [makeMain=false] - [description] - * @param {string} [name=''] - [description] + * @param {integer} [x=0] - The horizontal position of the Camera viewport. + * @param {integer} [y=0] - The vertical position of the Camera viewport. + * @param {integer} [width] - The width of the Camera viewport. If not given it'll be the game config size. + * @param {integer} [height] - The height of the Camera viewport. If not given it'll be the game config size. + * @param {boolean} [makeMain=false] - Set this Camera as being the 'main' camera. This just makes the property `main` a reference to it. + * @param {string} [name=''] - The name of the Camera. * - * @return {Phaser.Cameras.Scene2D.Camera} [description] + * @return {Phaser.Cameras.Scene2D.Camera} The newly created Camera. */ add: function (x, y, width, height, makeMain, name) { @@ -217,15 +252,22 @@ var CameraManager = new Class({ }, /** - * [description] + * Adds an existing Camera into the Camera Manager. + * + * The Camera should either be a `Phaser.Cameras.Scene2D.Camera` instance, or a class that extends from it. + * + * The Camera will be assigned an ID, which is used for Game Object exclusion and then added to the + * manager. As long as it doesn't already exist in the manager it will be added then returned. + * + * If this method returns `null` then the Camera already exists in this Camera Manager. * * @method Phaser.Cameras.Scene2D.CameraManager#addExisting * @since 3.0.0 * - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {boolean} [makeMain=false] - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to be added to the Camera Manager. + * @param {boolean} [makeMain=false] - Set this Camera as being the 'main' camera. This just makes the property `main` a reference to it. * - * @return {Phaser.Cameras.Scene2D.Camera} [description] + * @return {?Phaser.Cameras.Scene2D.Camera} The Camera that was added to the Camera Manager, or `null` if it couldn't be added. */ addExisting: function (camera, makeMain) { @@ -253,14 +295,16 @@ var CameraManager = new Class({ }, /** - * [description] + * Populates this Camera Manager based on the given configuration object, or an array of config objects. + * + * See the `InputJSONCameraObject` documentation for details of the object structure. * * @method Phaser.Cameras.Scene2D.CameraManager#fromJSON * @since 3.0.0 * - * @param {(InputJSONCameraObject|InputJSONCameraObject[])} config - [description] + * @param {(InputJSONCameraObject|InputJSONCameraObject[])} config - A Camera configuration object, or an array of them, to be added to this Camera Manager. * - * @return {Phaser.Cameras.Scene2D.CameraManager} [description] + * @return {Phaser.Cameras.Scene2D.CameraManager} This Camera Manager instance. */ fromJSON: function (config) { @@ -320,14 +364,17 @@ var CameraManager = new Class({ }, /** - * [description] + * Gets a Camera based on its name. + * + * Camera names are optional and don't have to be set, so this method is only of any use if you + * have given your Cameras unique names. * * @method Phaser.Cameras.Scene2D.CameraManager#getCamera * @since 3.0.0 * - * @param {string} name - [description] + * @param {string} name - The name of the Camera. * - * @return {?Phaser.Cameras.Scene2D.Camera} [description] + * @return {?Phaser.Cameras.Scene2D.Camera} The first Camera with a name matching the given string, otherwise `null`. */ getCamera: function (name) { @@ -380,12 +427,18 @@ var CameraManager = new Class({ }, /** - * [description] + * Removes the given Camera from this Camera Manager. + * + * If found in the Camera Manager it will be immediately removed from the local cameras array. + * If also currently the 'main' camera, 'main' will be reset to be camera 0. + * + * The removed Camera is not destroyed. If you also wish to destroy the Camera, you should call + * `Camera.destroy` on it, so that it clears all references to the Camera Manager. * * @method Phaser.Cameras.Scene2D.CameraManager#remove * @since 3.0.0 * - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to be removed from this Camera Manager. */ remove: function (camera) { @@ -403,9 +456,13 @@ var CameraManager = new Class({ }, /** - * [description] + * The internal render method. This is called automatically by the Scene and should not be invoked directly. + * + * It will iterate through all local cameras and render them in turn, as long as they're visible and have + * an alpha level > 0. * * @method Phaser.Cameras.Scene2D.CameraManager#render + * @protected * @since 3.0.0 * * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - The Renderer that will render the children to this camera. @@ -433,12 +490,15 @@ var CameraManager = new Class({ }, /** - * [description] + * Resets this Camera Manager. + * + * This will iterate through all current Cameras, destroying them all, then it will reset the + * cameras array, reset the ID counter and create 1 new single camera using the default values. * * @method Phaser.Cameras.Scene2D.CameraManager#resetAll * @since 3.0.0 * - * @return {Phaser.Cameras.Scene2D.Camera} [description] + * @return {Phaser.Cameras.Scene2D.Camera} The freshly created main Camera. */ resetAll: function () { @@ -457,13 +517,14 @@ var CameraManager = new Class({ }, /** - * [description] + * The main update loop. Called automatically when the Scene steps. * * @method Phaser.Cameras.Scene2D.CameraManager#update + * @protected * @since 3.0.0 * - * @param {number} timestep - [description] - * @param {number} delta - [description] + * @param {number} timestep - The timestep value. + * @param {number} delta - The delta value since the last frame. */ update: function (timestep, delta) { From 0fdeec2e26e3f65e8f7c0a021f2d683ece67b877 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Tue, 26 Jun 2018 17:43:05 +0100 Subject: [PATCH 27/48] Updated docs --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 356b6f9eb..f8a098d32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,9 +6,10 @@ * All of the 2D Camera classes are now 100% covered by JSDocs! * `Camera.alpha` (and its related method `Camera.setAlpha`) allows you to set an alpha level for the entire camera. This impacts everything it is rendering, even if those objects also have their own alpha values too. You can tween the property to make the camera contents fade in / out, or otherwise set it as needed in your game. -* `Camera.deadzone` (and its related method `Camera.setDeadzone`) allows you to specify the deadzone for a camera. The deadzone is a rectangular region used when a camera is following a target. If the target is within the deadzone then the camera will not scroll. As soon as the target leaves the deadzone, the camera will begin tracking it (applying lerp if needed.) It allows you to set a region of the camera in which a player can move freely before tracking begins. The deadzone is re-centered on the camera mid point every frame, meaning you can also use the rectangle for other in-game chcecks as needed. +* `Camera.deadzone` (and its related method `Camera.setDeadzone`) allows you to specify the deadzone for a camera. The deadzone is a rectangular region used when a camera is following a target. If the target is within the deadzone then the camera will not scroll. As soon as the target leaves the deadzone, the camera will begin tracking it (applying lerp if needed.) It allows you to set a region of the camera in which a player can move freely before tracking begins. The deadzone is re-centered on the camera mid point every frame, meaning you can also use the rectangle for other in-game checks as needed. * `Camera.pan` is a new Camera Effect that allows you to control automatic camera pans between points in your game world. You can specify a duration and ease type for the pan, and it'll emit events just like all other camera effects, so you can hook into the start, update and completion of the pan. See the examples and docs for more details. * `Camera.zoom` is a new Camera Effect that allows you to control automatic camera zooming. You can specify a duration and ease type for the zoom, as well as the zoom factor of course, and it'll emit events just like all other camera effects, so you can hook into the start, update and completion of the zoom. Used in combination with the new Pan effect you can zoom and pan around with ease. See the examples and docs for more details. +* The Camera Manager has 10 new read-only properties: `camera1`, `camera2` and so on, up to `camera10` so you can now quickly access the first 10 cameras created in the Camera Manager without needing to hold your own references too. * `Camera.midPoint` is a new Vec2 property that is updated every frame. Use it to obtain exactly where in the world the center of the camera is currently looking. * `Camera.displayWidth` is a new property that returns the display width of the camera, factoring in the current zoom level. * `Camera.displayHeight` is a new property that returns the display height of the camera, factoring in the current zoom level. @@ -53,7 +54,6 @@ * `Bob.setFrame` didn't actually set the frame on the Bob, now it does. Fix #3774 (thanks @NokFrt) * `Bob.alpha` was ignored by the canvas renderer, only working in WebGL. This has now been fixed. * Although the Blitter object had the Alpha component, setting it made no difference. Setting Blitter alpha now impacts the rendering of all children, in both Canvas and WebGL, and you can also specify an alpha per Bob as well. -* `Camera.centerToBounds` didn't take the bounds offset into account, so bounds at non-zero positions wouldn't center properly. All bounds now center correctly. Fix #3706 (thanks @cyantree) * `SceneManager.run` would ignore scenes that are currently in the queue of scenes pending to be added. This has now been fixed so that the scene is queued to be started once it's ready (thanks @rook2pawn) * `GameObject.disableInteractive` was toggling input. Every second call would turn the input back on (thanks @TadejZupancic) * The position of the TilemapLayer wasn't taken into account when culling tiles for the Camera. It's now calculated as part of the cull flow (thanks @Upperfoot) From 7aa46657c278c4f1ea285c1b4ac1bf95827469a9 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Tue, 26 Jun 2018 23:19:14 +0100 Subject: [PATCH 28/48] Tidying up jsdocs and changing float to number --- src/animations/Animation.js | 4 +- src/cameras/2d/Camera.js | 12 +- src/cameras/2d/CameraManager.js | 8 +- src/cameras/2d/effects/Fade.js | 6 +- src/cameras/2d/effects/Flash.js | 6 +- src/cameras/2d/effects/Pan.js | 4 +- src/cameras/2d/effects/Shake.js | 6 +- src/cameras/controls/FixedKeyControl.js | 10 +- src/cameras/controls/SmoothedKeyControl.js | 22 +- src/cameras/sprite3d/Camera.js | 6 +- src/cameras/sprite3d/OrthographicCamera.js | 2 +- src/curves/CubicBezierCurve.js | 2 +- src/curves/Curve.js | 8 +- src/curves/EllipseCurve.js | 2 +- src/curves/LineCurve.js | 4 +- src/curves/QuadraticBezierCurve.js | 2 +- src/curves/SplineCurve.js | 2 +- src/curves/path/MoveTo.js | 4 +- src/display/color/Color.js | 16 +- src/gameobjects/blitter/Bob.js | 2 +- src/gameobjects/components/Alpha.js | 28 +-- src/gameobjects/components/Animation.js | 4 +- src/gameobjects/components/Origin.js | 8 +- src/gameobjects/components/ToJSON.js | 6 +- src/gameobjects/components/Transform.js | 6 +- src/gameobjects/lights/LightsManager.js | 2 +- src/gameobjects/mesh/MeshFactory.js | 8 +- src/gameobjects/particles/GravityWell.js | 2 +- src/gameobjects/particles/Particle.js | 12 +- src/gameobjects/particles/ParticleEmitter.js | 64 +++--- src/gameobjects/quad/Quad.js | 8 +- src/geom/circle/Circle.js | 2 +- src/geom/circle/GetPoint.js | 2 +- src/geom/ellipse/Ellipse.js | 2 +- src/geom/ellipse/GetPoint.js | 2 +- src/geom/intersects/RectangleToValues.js | 2 +- src/geom/point/Interpolate.js | 2 +- src/geom/rectangle/GetPoint.js | 2 +- src/geom/rectangle/Rectangle.js | 2 +- src/geom/triangle/BuildFromPolygon.js | 4 +- src/geom/triangle/GetPoint.js | 2 +- src/geom/triangle/Triangle.js | 2 +- src/input/gamepad/Axis.js | 8 +- src/input/gamepad/Button.js | 4 +- src/loader/File.js | 2 +- src/loader/LoaderPlugin.js | 4 +- src/math/DegToRad.js | 2 +- src/math/FloatBetween.js | 6 +- src/math/FromPercent.js | 2 +- src/math/Linear.js | 2 +- src/math/Matrix4.js | 10 +- src/math/Percent.js | 2 +- src/math/RadToDeg.js | 2 +- src/math/RandomXY.js | 2 +- src/math/RandomXYZW.js | 2 +- src/math/Vector2.js | 4 +- src/math/easing/elastic/In.js | 4 +- src/math/easing/elastic/InOut.js | 4 +- src/math/easing/elastic/Out.js | 4 +- src/math/fuzzy/Ceil.js | 2 +- src/math/fuzzy/Equal.js | 2 +- src/math/fuzzy/Floor.js | 2 +- src/math/fuzzy/GreaterThan.js | 2 +- src/math/fuzzy/LessThan.js | 2 +- .../interpolation/CubicBezierInterpolation.js | 2 +- .../QuadraticBezierInterpolation.js | 2 +- src/physics/impact/World.js | 4 +- src/physics/matter-js/components/Bounce.js | 2 +- src/renderer/canvas/CanvasRenderer.js | 6 +- src/renderer/snapshot/CanvasSnapshot.js | 2 +- src/renderer/snapshot/WebGLSnapshot.js | 2 +- src/renderer/webgl/WebGLPipeline.js | 20 +- src/renderer/webgl/WebGLRenderer.js | 24 +-- .../webgl/pipelines/FlatTintPipeline.js | 194 +++++++++--------- .../webgl/pipelines/TextureTintPipeline.js | 34 +-- src/scene/ScenePlugin.js | 2 +- src/tilemaps/mapdata/LayerData.js | 2 +- src/time/Clock.js | 2 +- src/tweens/TweenManager.js | 2 +- src/tweens/tween/Tween.js | 4 +- 80 files changed, 339 insertions(+), 339 deletions(-) diff --git a/src/animations/Animation.js b/src/animations/Animation.js index cf2107c0f..c6f83bf8b 100644 --- a/src/animations/Animation.js +++ b/src/animations/Animation.js @@ -32,7 +32,7 @@ var GetValue = require('../utils/object/GetValue'); * * @property {string} key - The key that the animation will be associated with. i.e. sprite.animations.play(key) * @property {(string|number)} frame - [description] - * @property {float} [duration=0] - [description] + * @property {number} [duration=0] - [description] * @property {boolean} [visible] - [description] */ @@ -545,7 +545,7 @@ var Animation = new Class({ * @method Phaser.Animations.Animation#getFrameByProgress * @since 3.4.0 * - * @param {float} value - A value between 0 and 1. + * @param {number} value - A value between 0 and 1. * * @return {Phaser.Animations.AnimationFrame} The frame closest to the given progress value. */ diff --git a/src/cameras/2d/Camera.js b/src/cameras/2d/Camera.js index e1cbb1db2..5ec5471e2 100644 --- a/src/cameras/2d/Camera.js +++ b/src/cameras/2d/Camera.js @@ -262,7 +262,7 @@ var Camera = new Class({ * Be careful to never set this value to zero. * * @name Phaser.Cameras.Scene2D.Camera#zoom - * @type {float} + * @type {number} * @default 1 * @since 3.0.0 */ @@ -452,7 +452,7 @@ var Camera = new Class({ * See `setOrigin` to set both origins in a single, chainable call. * * @name Phaser.Cameras.Scene2D.Camera#originX - * @type {float} + * @type {number} * @default 0.5 * @since 3.11.0 */ @@ -469,7 +469,7 @@ var Camera = new Class({ * See `setOrigin` to set both origins in a single, chainable call. * * @name Phaser.Cameras.Scene2D.Camera#originY - * @type {float} + * @type {number} * @default 0.5 * @since 3.11.0 */ @@ -1590,7 +1590,7 @@ var Camera = new Class({ * @method Phaser.Cameras.Scene2D.Camera#setZoom * @since 3.0.0 * - * @param {float} [value=1] - The zoom value of the Camera. The minimum it can be is 0.001. + * @param {number} [value=1] - The zoom value of the Camera. The minimum it can be is 0.001. * * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. */ @@ -1646,8 +1646,8 @@ var Camera = new Class({ * * @param {(Phaser.GameObjects.GameObject|object)} target - The target for the Camera to follow. * @param {boolean} [roundPixels=false] - Round the camera position to whole integers to avoid sub-pixel rendering? - * @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. - * @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. + * @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. + * @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. * @param {number} [offsetX=0] - The horizontal offset from the camera follow target.x position. * @param {number} [offsetY=0] - The vertical offset from the camera follow target.y position. * diff --git a/src/cameras/2d/CameraManager.js b/src/cameras/2d/CameraManager.js index fbe2cda31..5a256bc5d 100644 --- a/src/cameras/2d/CameraManager.js +++ b/src/cameras/2d/CameraManager.js @@ -18,11 +18,11 @@ var RectangleContains = require('../../geom/rectangle/Contains'); * @property {integer} [y=0] - The vertical position of the Camera viewport. * @property {integer} [width] - The width of the Camera viewport. * @property {integer} [height] - The height of the Camera viewport. - * @property {float} [zoom=1] - The default zoom level of the Camera. - * @property {float} [rotation=0] - The rotation of the Camera, in radians. + * @property {number} [zoom=1] - The default zoom level of the Camera. + * @property {number} [rotation=0] - The rotation of the Camera, in radians. * @property {boolean} [roundPixels=false] - Should the Camera round pixels before rendering? - * @property {float} [scrollX=0] - The horizontal scroll position of the Camera. - * @property {float} [scrollY=0] - The vertical scroll position of the Camera. + * @property {number} [scrollX=0] - The horizontal scroll position of the Camera. + * @property {number} [scrollY=0] - The vertical scroll position of the Camera. * @property {(false|string)} [backgroundColor=false] - A CSS color string controlling the Camera background color. * @property {?object} [bounds] - Defines the Camera bounds. * @property {number} [bounds.x=0] - The top-left extent of the Camera bounds. diff --git a/src/cameras/2d/effects/Fade.js b/src/cameras/2d/effects/Fade.js index 40c9e4e55..d4ecc44d3 100644 --- a/src/cameras/2d/effects/Fade.js +++ b/src/cameras/2d/effects/Fade.js @@ -127,7 +127,7 @@ var Fade = new Class({ * A value between 0 and 1. * * @name Phaser.Cameras.Scene2D.Effects.Fade#alpha - * @type {float} + * @type {number} * @private * @since 3.5.0 */ @@ -137,7 +137,7 @@ var Fade = new Class({ * If this effect is running this holds the current percentage of the progress, a value between 0 and 1. * * @name Phaser.Cameras.Scene2D.Effects.Fade#progress - * @type {float} + * @type {number} * @since 3.5.0 */ this.progress = 0; @@ -156,7 +156,7 @@ var Fade = new Class({ * @callback CameraFadeCallback * * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera on which the effect is running. - * @param {float} progress - The progress of the effect. A value between 0 and 1. + * @param {number} progress - The progress of the effect. A value between 0 and 1. */ /** diff --git a/src/cameras/2d/effects/Flash.js b/src/cameras/2d/effects/Flash.js index a6abe6c83..f314e5bee 100644 --- a/src/cameras/2d/effects/Flash.js +++ b/src/cameras/2d/effects/Flash.js @@ -102,7 +102,7 @@ var Flash = new Class({ * A value between 0 and 1. * * @name Phaser.Cameras.Scene2D.Effects.Flash#alpha - * @type {float} + * @type {number} * @private * @since 3.5.0 */ @@ -112,7 +112,7 @@ var Flash = new Class({ * If this effect is running this holds the current percentage of the progress, a value between 0 and 1. * * @name Phaser.Cameras.Scene2D.Effects.Flash#progress - * @type {float} + * @type {number} * @since 3.5.0 */ this.progress = 0; @@ -131,7 +131,7 @@ var Flash = new Class({ * @callback CameraFlashCallback * * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera on which the effect is running. - * @param {float} progress - The progress of the effect. A value between 0 and 1. + * @param {number} progress - The progress of the effect. A value between 0 and 1. */ /** diff --git a/src/cameras/2d/effects/Pan.js b/src/cameras/2d/effects/Pan.js index a9c3140cd..a55bdd690 100644 --- a/src/cameras/2d/effects/Pan.js +++ b/src/cameras/2d/effects/Pan.js @@ -107,7 +107,7 @@ var Pan = new Class({ * If this effect is running this holds the current percentage of the progress, a value between 0 and 1. * * @name Phaser.Cameras.Scene2D.Effects.Pan#progress - * @type {float} + * @type {number} * @since 3.11.0 */ this.progress = 0; @@ -126,7 +126,7 @@ var Pan = new Class({ * @callback CameraPanCallback * * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera on which the effect is running. - * @param {float} progress - The progress of the effect. A value between 0 and 1. + * @param {number} progress - The progress of the effect. A value between 0 and 1. * @param {number} x - The Camera's new scrollX coordinate. * @param {number} y - The Camera's new scrollY coordinate. */ diff --git a/src/cameras/2d/effects/Shake.js b/src/cameras/2d/effects/Shake.js index 930afeb4d..d809f69f1 100644 --- a/src/cameras/2d/effects/Shake.js +++ b/src/cameras/2d/effects/Shake.js @@ -80,7 +80,7 @@ var Shake = new Class({ * If this effect is running this holds the current percentage of the progress, a value between 0 and 1. * * @name Phaser.Cameras.Scene2D.Effects.Shake#progress - * @type {float} + * @type {number} * @since 3.5.0 */ this.progress = 0; @@ -121,7 +121,7 @@ var Shake = new Class({ * @callback CameraShakeCallback * * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera on which the effect is running. - * @param {float} progress - The progress of the effect. A value between 0 and 1. + * @param {number} progress - The progress of the effect. A value between 0 and 1. */ /** @@ -153,7 +153,7 @@ var Shake = new Class({ * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on. * @param {Phaser.Cameras.Scene2D.Effects.Shake} effect - A reference to the effect instance. * @param {integer} duration - The duration of the effect. - * @param {float} intensity - The intensity of the effect. + * @param {number} intensity - The intensity of the effect. */ /** diff --git a/src/cameras/controls/FixedKeyControl.js b/src/cameras/controls/FixedKeyControl.js index d7fc82c63..cb2ec29db 100644 --- a/src/cameras/controls/FixedKeyControl.js +++ b/src/cameras/controls/FixedKeyControl.js @@ -23,8 +23,8 @@ var GetValue = require('../../utils/object/GetValue'); * @property {Phaser.Input.Keyboard.Key} [up] - The Key to be pressed that will move the Camera up. * @property {Phaser.Input.Keyboard.Key} [zoomIn] - The Key to be pressed that will zoom the Camera in. * @property {Phaser.Input.Keyboard.Key} [zoomOut] - The Key to be pressed that will zoom the Camera out. - * @property {float} [zoomSpeed=0.01] - The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. - * @property {(float|{x:float,y:float})} [speed=0] - The horizontal and vertical speed the camera will move. + * @property {number} [zoomSpeed=0.01] - The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. + * @property {(number|{x:number,y:number})} [speed=0] - The horizontal and vertical speed the camera will move. */ /** @@ -118,7 +118,7 @@ var FixedKeyControl = new Class({ * The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. * * @name Phaser.Cameras.Controls.FixedKeyControl#zoomSpeed - * @type {float} + * @type {number} * @default 0.01 * @since 3.0.0 */ @@ -128,7 +128,7 @@ var FixedKeyControl = new Class({ * The horizontal speed the camera will move. * * @name Phaser.Cameras.Controls.FixedKeyControl#speedX - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 */ @@ -138,7 +138,7 @@ var FixedKeyControl = new Class({ * The vertical speed the camera will move. * * @name Phaser.Cameras.Controls.FixedKeyControl#speedY - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 */ diff --git a/src/cameras/controls/SmoothedKeyControl.js b/src/cameras/controls/SmoothedKeyControl.js index b211f7c63..b3724b581 100644 --- a/src/cameras/controls/SmoothedKeyControl.js +++ b/src/cameras/controls/SmoothedKeyControl.js @@ -30,10 +30,10 @@ var GetValue = require('../../utils/object/GetValue'); * @property {Phaser.Input.Keyboard.Key} [up] - The Key to be pressed that will move the Camera up. * @property {Phaser.Input.Keyboard.Key} [zoomIn] - The Key to be pressed that will zoom the Camera in. * @property {Phaser.Input.Keyboard.Key} [zoomOut] - The Key to be pressed that will zoom the Camera out. - * @property {float} [zoomSpeed=0.01] - The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. - * @property {(float|{x:float,y:float})} [acceleration=0] - The horizontal and vertical acceleration the camera will move. - * @property {(float|{x:float,y:float})} [drag=0] - The horizontal and vertical drag applied to the camera when it is moving. - * @property {(float|{x:float,y:float})} [maxSpeed=0] - The maximum horizontal and vertical speed the camera will move. + * @property {number} [zoomSpeed=0.01] - The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. + * @property {(number|{x:number,y:number})} [acceleration=0] - The horizontal and vertical acceleration the camera will move. + * @property {(number|{x:number,y:number})} [drag=0] - The horizontal and vertical drag applied to the camera when it is moving. + * @property {(number|{x:number,y:number})} [maxSpeed=0] - The maximum horizontal and vertical speed the camera will move. */ /** @@ -127,7 +127,7 @@ var SmoothedKeyControl = new Class({ * The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. * * @name Phaser.Cameras.Controls.SmoothedKeyControl#zoomSpeed - * @type {float} + * @type {number} * @default 0.01 * @since 3.0.0 */ @@ -137,7 +137,7 @@ var SmoothedKeyControl = new Class({ * The horizontal acceleration the camera will move. * * @name Phaser.Cameras.Controls.SmoothedKeyControl#accelX - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 */ @@ -147,7 +147,7 @@ var SmoothedKeyControl = new Class({ * The vertical acceleration the camera will move. * * @name Phaser.Cameras.Controls.SmoothedKeyControl#accelY - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 */ @@ -170,7 +170,7 @@ var SmoothedKeyControl = new Class({ * The horizontal drag applied to the camera when it is moving. * * @name Phaser.Cameras.Controls.SmoothedKeyControl#dragX - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 */ @@ -180,7 +180,7 @@ var SmoothedKeyControl = new Class({ * The vertical drag applied to the camera when it is moving. * * @name Phaser.Cameras.Controls.SmoothedKeyControl#dragY - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 */ @@ -203,7 +203,7 @@ var SmoothedKeyControl = new Class({ * The maximum horizontal speed the camera will move. * * @name Phaser.Cameras.Controls.SmoothedKeyControl#maxSpeedX - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 */ @@ -213,7 +213,7 @@ var SmoothedKeyControl = new Class({ * The maximum vertical speed the camera will move. * * @name Phaser.Cameras.Controls.SmoothedKeyControl#maxSpeedY - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 */ diff --git a/src/cameras/sprite3d/Camera.js b/src/cameras/sprite3d/Camera.js index 735349ad6..58a909b56 100644 --- a/src/cameras/sprite3d/Camera.js +++ b/src/cameras/sprite3d/Camera.js @@ -504,7 +504,7 @@ var Camera = new Class({ * @method Phaser.Cameras.Sprite3D.Camera#randomCube * @since 3.0.0 * - * @param {float} [scale=1] - [description] + * @param {number} [scale=1] - [description] * @param {Phaser.GameObjects.Sprite3D[]} [sprites] - [description] * * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. @@ -662,7 +662,7 @@ var Camera = new Class({ * @method Phaser.Cameras.Sprite3D.Camera#rotate * @since 3.0.0 * - * @param {float} radians - [description] + * @param {number} radians - [description] * @param {Phaser.Math.Vector3} axis - [description] * * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. @@ -682,7 +682,7 @@ var Camera = new Class({ * @since 3.0.0 * * @param {Phaser.Math.Vector3} point - [description] - * @param {float} radians - [description] + * @param {number} radians - [description] * @param {Phaser.Math.Vector3} axis - [description] * * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. diff --git a/src/cameras/sprite3d/OrthographicCamera.js b/src/cameras/sprite3d/OrthographicCamera.js index 7b8db4d18..0727ba9ba 100644 --- a/src/cameras/sprite3d/OrthographicCamera.js +++ b/src/cameras/sprite3d/OrthographicCamera.js @@ -60,7 +60,7 @@ var OrthographicCamera = new Class({ * [description] * * @name Phaser.Cameras.Sprite3D.OrthographicCamera#_zoom - * @type {float} + * @type {number} * @private * @since 3.0.0 */ diff --git a/src/curves/CubicBezierCurve.js b/src/curves/CubicBezierCurve.js index 7d575ba78..d4ae536f2 100644 --- a/src/curves/CubicBezierCurve.js +++ b/src/curves/CubicBezierCurve.js @@ -123,7 +123,7 @@ var CubicBezierCurve = new Class({ * * @generic {Phaser.Math.Vector2} O - [out,$return] * - * @param {float} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {number} t - The position along the curve to return. Where 0 is the start and 1 is the end. * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. * * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. diff --git a/src/curves/Curve.js b/src/curves/Curve.js index 908cc672f..66115a756 100644 --- a/src/curves/Curve.js +++ b/src/curves/Curve.js @@ -278,7 +278,7 @@ var Curve = new Class({ * * @generic {Phaser.Math.Vector2} O - [out,$return] * - * @param {float} u - [description] + * @param {number} u - [description] * @param {Phaser.Math.Vector2} [out] - [description] * * @return {Phaser.Math.Vector2} [description] @@ -434,7 +434,7 @@ var Curve = new Class({ * * @generic {Phaser.Math.Vector2} O - [out,$return] * - * @param {float} u - [description] + * @param {number} u - [description] * @param {Phaser.Math.Vector2} [out] - [description] * * @return {Phaser.Math.Vector2} [description] @@ -456,7 +456,7 @@ var Curve = new Class({ * @param {integer} distance - [description] * @param {integer} [divisions] - [description] * - * @return {float} [description] + * @return {number} [description] */ getTFromDistance: function (distance, divisions) { @@ -476,7 +476,7 @@ var Curve = new Class({ * @method Phaser.Curves.Curve#getUtoTmapping * @since 3.0.0 * - * @param {float} u - [description] + * @param {number} u - [description] * @param {integer} distance - [description] * @param {integer} [divisions] - [description] * diff --git a/src/curves/EllipseCurve.js b/src/curves/EllipseCurve.js index d036941e7..352843775 100644 --- a/src/curves/EllipseCurve.js +++ b/src/curves/EllipseCurve.js @@ -207,7 +207,7 @@ var EllipseCurve = new Class({ * * @generic {Phaser.Math.Vector2} O - [out,$return] * - * @param {float} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {number} t - The position along the curve to return. Where 0 is the start and 1 is the end. * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. * * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. diff --git a/src/curves/LineCurve.js b/src/curves/LineCurve.js index 2ba95ef9e..2d8a874b4 100644 --- a/src/curves/LineCurve.js +++ b/src/curves/LineCurve.js @@ -126,7 +126,7 @@ var LineCurve = new Class({ * * @generic {Phaser.Math.Vector2} O - [out,$return] * - * @param {float} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {number} t - The position along the curve to return. Where 0 is the start and 1 is the end. * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. * * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. @@ -155,7 +155,7 @@ var LineCurve = new Class({ * * @generic {Phaser.Math.Vector2} O - [out,$return] * - * @param {float} u - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {number} u - The position along the curve to return. Where 0 is the start and 1 is the end. * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. * * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. diff --git a/src/curves/QuadraticBezierCurve.js b/src/curves/QuadraticBezierCurve.js index f4d312f49..3028330b7 100644 --- a/src/curves/QuadraticBezierCurve.js +++ b/src/curves/QuadraticBezierCurve.js @@ -110,7 +110,7 @@ var QuadraticBezier = new Class({ * * @generic {Phaser.Math.Vector2} O - [out,$return] * - * @param {float} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {number} t - The position along the curve to return. Where 0 is the start and 1 is the end. * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. * * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. diff --git a/src/curves/SplineCurve.js b/src/curves/SplineCurve.js index 067e5e5da..55cf98b64 100644 --- a/src/curves/SplineCurve.js +++ b/src/curves/SplineCurve.js @@ -150,7 +150,7 @@ var SplineCurve = new Class({ * * @generic {Phaser.Math.Vector2} O - [out,$return] * - * @param {float} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {number} t - The position along the curve to return. Where 0 is the start and 1 is the end. * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. * * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. diff --git a/src/curves/path/MoveTo.js b/src/curves/path/MoveTo.js index f35dbd430..50388b23a 100644 --- a/src/curves/path/MoveTo.js +++ b/src/curves/path/MoveTo.js @@ -55,7 +55,7 @@ var MoveTo = new Class({ * * @generic {Phaser.Math.Vector2} O - [out,$return] * - * @param {float} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {number} t - The position along the curve to return. Where 0 is the start and 1 is the end. * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. * * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. @@ -75,7 +75,7 @@ var MoveTo = new Class({ * * @generic {Phaser.Math.Vector2} O - [out,$return] * - * @param {float} u - [description] + * @param {number} u - [description] * @param {Phaser.Math.Vector2} [out] - [description] * * @return {Phaser.Math.Vector2} [description] diff --git a/src/display/color/Color.js b/src/display/color/Color.js index fe5dec751..827c38620 100644 --- a/src/display/color/Color.js +++ b/src/display/color/Color.js @@ -171,10 +171,10 @@ var Color = new Class({ * @method Phaser.Display.Color#setGLTo * @since 3.0.0 * - * @param {float} red - The red color value. A number between 0 and 1. - * @param {float} green - The green color value. A number between 0 and 1. - * @param {float} blue - The blue color value. A number between 0 and 1. - * @param {float} [alpha=1] - The alpha value. A number between 0 and 1. + * @param {number} red - The red color value. A number between 0 and 1. + * @param {number} green - The green color value. A number between 0 and 1. + * @param {number} blue - The blue color value. A number between 0 and 1. + * @param {number} [alpha=1] - The alpha value. A number between 0 and 1. * * @return {Phaser.Display.Color} This Color object. */ @@ -299,7 +299,7 @@ var Color = new Class({ * The red color value, normalized to the range 0 to 1. * * @name Phaser.Display.Color#redGL - * @type {float} + * @type {number} * @since 3.0.0 */ redGL: { @@ -324,7 +324,7 @@ var Color = new Class({ * The green color value, normalized to the range 0 to 1. * * @name Phaser.Display.Color#greenGL - * @type {float} + * @type {number} * @since 3.0.0 */ greenGL: { @@ -349,7 +349,7 @@ var Color = new Class({ * The blue color value, normalized to the range 0 to 1. * * @name Phaser.Display.Color#blueGL - * @type {float} + * @type {number} * @since 3.0.0 */ blueGL: { @@ -374,7 +374,7 @@ var Color = new Class({ * The alpha color value, normalized to the range 0 to 1. * * @name Phaser.Display.Color#alphaGL - * @type {float} + * @type {number} * @since 3.0.0 */ alphaGL: { diff --git a/src/gameobjects/blitter/Bob.js b/src/gameobjects/blitter/Bob.js index a92b9f84b..d4dd9cab5 100644 --- a/src/gameobjects/blitter/Bob.js +++ b/src/gameobjects/blitter/Bob.js @@ -291,7 +291,7 @@ var Bob = new Class({ * @method Phaser.GameObjects.Blitter.Bob#setAlpha * @since 3.0.0 * - * @param {float} value - The alpha value used for this Bob. Between 0 and 1. + * @param {number} value - The alpha value used for this Bob. Between 0 and 1. * * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. */ diff --git a/src/gameobjects/components/Alpha.js b/src/gameobjects/components/Alpha.js index e53928112..0f32a9173 100644 --- a/src/gameobjects/components/Alpha.js +++ b/src/gameobjects/components/Alpha.js @@ -23,7 +23,7 @@ var Alpha = { * Private internal value. Holds the global alpha value. * * @name Phaser.GameObjects.Components.Alpha#_alpha - * @type {float} + * @type {number} * @private * @default 1 * @since 3.0.0 @@ -34,7 +34,7 @@ var Alpha = { * Private internal value. Holds the top-left alpha value. * * @name Phaser.GameObjects.Components.Alpha#_alphaTL - * @type {float} + * @type {number} * @private * @default 1 * @since 3.0.0 @@ -45,7 +45,7 @@ var Alpha = { * Private internal value. Holds the top-right alpha value. * * @name Phaser.GameObjects.Components.Alpha#_alphaTR - * @type {float} + * @type {number} * @private * @default 1 * @since 3.0.0 @@ -56,7 +56,7 @@ var Alpha = { * Private internal value. Holds the bottom-left alpha value. * * @name Phaser.GameObjects.Components.Alpha#_alphaBL - * @type {float} + * @type {number} * @private * @default 1 * @since 3.0.0 @@ -67,7 +67,7 @@ var Alpha = { * Private internal value. Holds the bottom-right alpha value. * * @name Phaser.GameObjects.Components.Alpha#_alphaBR - * @type {float} + * @type {number} * @private * @default 1 * @since 3.0.0 @@ -99,10 +99,10 @@ var Alpha = { * @method Phaser.GameObjects.Components.Alpha#setAlpha * @since 3.0.0 * - * @param {float} [topLeft=1] - The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. - * @param {float} [topRight] - The alpha value used for the top-right of the Game Object. WebGL only. - * @param {float} [bottomLeft] - The alpha value used for the bottom-left of the Game Object. WebGL only. - * @param {float} [bottomRight] - The alpha value used for the bottom-right of the Game Object. WebGL only. + * @param {number} [topLeft=1] - The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. + * @param {number} [topRight] - The alpha value used for the top-right of the Game Object. WebGL only. + * @param {number} [bottomLeft] - The alpha value used for the bottom-left of the Game Object. WebGL only. + * @param {number} [bottomRight] - The alpha value used for the bottom-right of the Game Object. WebGL only. * * @return {this} This Game Object instance. */ @@ -132,7 +132,7 @@ var Alpha = { * This is a global value, impacting the entire Game Object, not just a region of it. * * @name Phaser.GameObjects.Components.Alpha#alpha - * @type {float} + * @type {number} * @since 3.0.0 */ alpha: { @@ -169,7 +169,7 @@ var Alpha = { * This value is interpolated from the corner to the center of the Game Object. * * @name Phaser.GameObjects.Components.Alpha#alphaTopLeft - * @type {float} + * @type {number} * @webglOnly * @since 3.0.0 */ @@ -199,7 +199,7 @@ var Alpha = { * This value is interpolated from the corner to the center of the Game Object. * * @name Phaser.GameObjects.Components.Alpha#alphaTopRight - * @type {float} + * @type {number} * @webglOnly * @since 3.0.0 */ @@ -229,7 +229,7 @@ var Alpha = { * This value is interpolated from the corner to the center of the Game Object. * * @name Phaser.GameObjects.Components.Alpha#alphaBottomLeft - * @type {float} + * @type {number} * @webglOnly * @since 3.0.0 */ @@ -259,7 +259,7 @@ var Alpha = { * This value is interpolated from the corner to the center of the Game Object. * * @name Phaser.GameObjects.Components.Alpha#alphaBottomRight - * @type {float} + * @type {number} * @webglOnly * @since 3.0.0 */ diff --git a/src/gameobjects/components/Animation.js b/src/gameobjects/components/Animation.js index e059381b2..97285362e 100644 --- a/src/gameobjects/components/Animation.js +++ b/src/gameobjects/components/Animation.js @@ -528,7 +528,7 @@ var Animation = new Class({ * @method Phaser.GameObjects.Components.Animation#getProgress * @since 3.4.0 * - * @return {float} The progress of the current animation, between 0 and 1. + * @return {number} The progress of the current animation, between 0 and 1. */ getProgress: function () { @@ -549,7 +549,7 @@ var Animation = new Class({ * @method Phaser.GameObjects.Components.Animation#setProgress * @since 3.4.0 * - * @param {float} [value=0] - The progress value, between 0 and 1. + * @param {number} [value=0] - The progress value, between 0 and 1. * * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. */ diff --git a/src/gameobjects/components/Origin.js b/src/gameobjects/components/Origin.js index a672db568..75fc1a7db 100644 --- a/src/gameobjects/components/Origin.js +++ b/src/gameobjects/components/Origin.js @@ -34,7 +34,7 @@ var Origin = { * Setting the value to 0 means the position now relates to the left of the Game Object. * * @name Phaser.GameObjects.Components.Origin#originX - * @type {float} + * @type {number} * @default 0.5 * @since 3.0.0 */ @@ -47,7 +47,7 @@ var Origin = { * Setting the value to 0 means the position now relates to the top of the Game Object. * * @name Phaser.GameObjects.Components.Origin#originY - * @type {float} + * @type {number} * @default 0.5 * @since 3.0.0 */ @@ -63,7 +63,7 @@ var Origin = { * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. * * @name Phaser.GameObjects.Components.Origin#displayOriginX - * @type {float} + * @type {number} * @since 3.0.0 */ displayOriginX: { @@ -87,7 +87,7 @@ var Origin = { * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. * * @name Phaser.GameObjects.Components.Origin#displayOriginY - * @type {float} + * @type {number} * @since 3.0.0 */ displayOriginY: { diff --git a/src/gameobjects/components/ToJSON.js b/src/gameobjects/components/ToJSON.js index 4b360a22d..3391a43bb 100644 --- a/src/gameobjects/components/ToJSON.js +++ b/src/gameobjects/components/ToJSON.js @@ -15,12 +15,12 @@ * @property {number} scale.x - The horizontal scale of this Game Object. * @property {number} scale.y - The vertical scale of this Game Object. * @property {object} origin - The origin of this Game Object. - * @property {float} origin.x - The horizontal origin of this Game Object. - * @property {float} origin.y - The vertical origin of this Game Object. + * @property {number} origin.x - The horizontal origin of this Game Object. + * @property {number} origin.y - The vertical origin of this Game Object. * @property {boolean} flipX - The horizontally flipped state of the Game Object. * @property {boolean} flipY - The vertically flipped state of the Game Object. * @property {number} rotation - The angle of this Game Object in radians. - * @property {float} alpha - The alpha value of the Game Object. + * @property {number} alpha - The alpha value of the Game Object. * @property {boolean} visible - The visible state of the Game Object. * @property {integer} scaleMode - The Scale Mode being used by this Game Object. * @property {(integer|string)} blendMode - Sets the Blend Mode being used by this Game Object. diff --git a/src/gameobjects/components/Transform.js b/src/gameobjects/components/Transform.js index 4db4f9427..b974c203b 100644 --- a/src/gameobjects/components/Transform.js +++ b/src/gameobjects/components/Transform.js @@ -25,7 +25,7 @@ var Transform = { * Private internal value. Holds the horizontal scale value. * * @name Phaser.GameObjects.Components.Transform#_scaleX - * @type {float} + * @type {number} * @private * @default 1 * @since 3.0.0 @@ -36,7 +36,7 @@ var Transform = { * Private internal value. Holds the vertical scale value. * * @name Phaser.GameObjects.Components.Transform#_scaleY - * @type {float} + * @type {number} * @private * @default 1 * @since 3.0.0 @@ -47,7 +47,7 @@ var Transform = { * Private internal value. Holds the rotation value in radians. * * @name Phaser.GameObjects.Components.Transform#_rotation - * @type {float} + * @type {number} * @private * @default 0 * @since 3.0.0 diff --git a/src/gameobjects/lights/LightsManager.js b/src/gameobjects/lights/LightsManager.js index ce9a64a23..788439f39 100644 --- a/src/gameobjects/lights/LightsManager.js +++ b/src/gameobjects/lights/LightsManager.js @@ -70,7 +70,7 @@ var LightsManager = new Class({ * The ambient color. * * @name Phaser.GameObjects.LightsManager#ambientColor - * @type {{ r: float, g: float, b: float }} + * @type {{ r: number, g: number, b: number }} * @since 3.0.0 */ this.ambientColor = { r: 0.1, g: 0.1, b: 0.1 }; diff --git a/src/gameobjects/mesh/MeshFactory.js b/src/gameobjects/mesh/MeshFactory.js index ee7eac382..aa021e351 100644 --- a/src/gameobjects/mesh/MeshFactory.js +++ b/src/gameobjects/mesh/MeshFactory.js @@ -18,10 +18,10 @@ var GameObjectFactory = require('../GameObjectFactory'); * * @param {number} x - The horizontal position of this Game Object in the world. * @param {number} y - The vertical position of this Game Object in the world. - * @param {float[]} vertices - An array containing the vertices data for this Mesh. - * @param {float[]} uv - An array containing the uv data for this Mesh. - * @param {float[]} colors - An array containing the color data for this Mesh. - * @param {float[]} alphas - An array containing the alpha data for this Mesh. + * @param {number[]} vertices - An array containing the vertices data for this Mesh. + * @param {number[]} uv - An array containing the uv data for this Mesh. + * @param {number[]} colors - An array containing the color data for this Mesh. + * @param {number[]} alphas - An array containing the alpha data for this Mesh. * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. * diff --git a/src/gameobjects/particles/GravityWell.js b/src/gameobjects/particles/GravityWell.js index 0dc575be9..82b5818e2 100644 --- a/src/gameobjects/particles/GravityWell.js +++ b/src/gameobjects/particles/GravityWell.js @@ -144,7 +144,7 @@ var GravityWell = new Class({ * * @param {Phaser.GameObjects.Particles.Particle} particle - The Particle to update. * @param {number} delta - The delta time in ms. - * @param {float} step - The delta value divided by 1000. + * @param {number} step - The delta value divided by 1000. */ update: function (particle, delta) { diff --git a/src/gameobjects/particles/Particle.js b/src/gameobjects/particles/Particle.js index f5c8c7e70..538fd1055 100644 --- a/src/gameobjects/particles/Particle.js +++ b/src/gameobjects/particles/Particle.js @@ -156,7 +156,7 @@ var Particle = new Class({ * The horizontal scale of this Particle. * * @name Phaser.GameObjects.Particles.Particle#scaleX - * @type {float} + * @type {number} * @default 1 * @since 3.0.0 */ @@ -166,7 +166,7 @@ var Particle = new Class({ * The vertical scale of this Particle. * * @name Phaser.GameObjects.Particles.Particle#scaleY - * @type {float} + * @type {number} * @default 1 * @since 3.0.0 */ @@ -176,7 +176,7 @@ var Particle = new Class({ * The alpha value of this Particle. * * @name Phaser.GameObjects.Particles.Particle#alpha - * @type {float} + * @type {number} * @default 1 * @since 3.0.0 */ @@ -255,7 +255,7 @@ var Particle = new Class({ * The normalized lifespan T value, where 0 is the start and 1 is the end. * * @name Phaser.GameObjects.Particles.Particle#lifeT - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 */ @@ -412,7 +412,7 @@ var Particle = new Class({ * * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - The Emitter that is updating this Particle. * @param {number} delta - The delta time in ms. - * @param {float} step - The delta value divided by 1000. + * @param {number} step - The delta value divided by 1000. * @param {array} processors - Particle processors (gravity wells). */ computeVelocity: function (emitter, delta, step, processors) @@ -514,7 +514,7 @@ var Particle = new Class({ * @since 3.0.0 * * @param {number} delta - The delta time in ms. - * @param {float} step - The delta value divided by 1000. + * @param {number} step - The delta value divided by 1000. * @param {array} processors - An optional array of update processors. * * @return {boolean} Returns `true` if this Particle has now expired and should be removed, otherwise `false` if still active. diff --git a/src/gameobjects/particles/ParticleEmitter.js b/src/gameobjects/particles/ParticleEmitter.js index dd6ec3467..585eb181b 100644 --- a/src/gameobjects/particles/ParticleEmitter.js +++ b/src/gameobjects/particles/ParticleEmitter.js @@ -625,7 +625,7 @@ var ParticleEmitter = new Class({ * Calling {@link Phaser.GameObjects.Particles.ParticleEmitter#explode} also puts the emitter in explode mode (frequency = -1). * * @name Phaser.GameObjects.Particles.ParticleEmitter#frequency - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 * @see Phaser.GameObjects.Particles.ParticleEmitter#setFrequency @@ -1207,8 +1207,8 @@ var ParticleEmitter = new Class({ * @method Phaser.GameObjects.Particles.ParticleEmitter#setPosition * @since 3.0.0 * - * @param {float|float[]|EmitterOpOnEmitCallback|object} x - The x-coordinate of the particle origin. - * @param {float|float[]|EmitterOpOnEmitCallback|object} y - The y-coordinate of the particle origin. + * @param {number|float[]|EmitterOpOnEmitCallback|object} x - The x-coordinate of the particle origin. + * @param {number|float[]|EmitterOpOnEmitCallback|object} y - The y-coordinate of the particle origin. * * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. */ @@ -1229,9 +1229,9 @@ var ParticleEmitter = new Class({ * @since 3.0.0 * * @param {(number|ParticleEmitterBounds|ParticleEmitterBoundsAlt)} x - The x-coordinate of the left edge of the boundary, or an object representing a rectangle. - * @param {float} y - The y-coordinate of the top edge of the boundary. - * @param {float} width - The width of the boundary. - * @param {float} height - The height of the boundary. + * @param {number} y - The y-coordinate of the top edge of the boundary. + * @param {number} width - The width of the boundary. + * @param {number} height - The height of the boundary. * * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. */ @@ -1266,7 +1266,7 @@ var ParticleEmitter = new Class({ * @method Phaser.GameObjects.Particles.ParticleEmitter#setSpeedX * @since 3.0.0 * - * @param {float|float[]|EmitterOpOnEmitCallback|object} value - The speed, in pixels per second. + * @param {number|float[]|EmitterOpOnEmitCallback|object} value - The speed, in pixels per second. * * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. */ @@ -1287,7 +1287,7 @@ var ParticleEmitter = new Class({ * @method Phaser.GameObjects.Particles.ParticleEmitter#setSpeedY * @since 3.0.0 * - * @param {float|float[]|EmitterOpOnEmitCallback|object} value - The speed, in pixels per second. + * @param {number|float[]|EmitterOpOnEmitCallback|object} value - The speed, in pixels per second. * * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. */ @@ -1311,7 +1311,7 @@ var ParticleEmitter = new Class({ * @method Phaser.GameObjects.Particles.ParticleEmitter#setSpeed * @since 3.0.0 * - * @param {float|float[]|EmitterOpOnEmitCallback|object} value - The speed, in pixels per second. + * @param {number|float[]|EmitterOpOnEmitCallback|object} value - The speed, in pixels per second. * * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. */ @@ -1332,7 +1332,7 @@ var ParticleEmitter = new Class({ * @method Phaser.GameObjects.Particles.ParticleEmitter#setScaleX * @since 3.0.0 * - * @param {float|float[]|EmitterOpOnUpdateCallback|object} value - The scale, relative to 1. + * @param {number|float[]|EmitterOpOnUpdateCallback|object} value - The scale, relative to 1. * * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. */ @@ -1349,7 +1349,7 @@ var ParticleEmitter = new Class({ * @method Phaser.GameObjects.Particles.ParticleEmitter#setScaleY * @since 3.0.0 * - * @param {float|float[]|EmitterOpOnUpdateCallback|object} value - The scale, relative to 1. + * @param {number|float[]|EmitterOpOnUpdateCallback|object} value - The scale, relative to 1. * * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. */ @@ -1366,7 +1366,7 @@ var ParticleEmitter = new Class({ * @method Phaser.GameObjects.Particles.ParticleEmitter#setScale * @since 3.0.0 * - * @param {float|float[]|EmitterOpOnUpdateCallback|object} value - The scale, relative to 1. + * @param {number|float[]|EmitterOpOnUpdateCallback|object} value - The scale, relative to 1. * * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. */ @@ -1384,7 +1384,7 @@ var ParticleEmitter = new Class({ * @method Phaser.GameObjects.Particles.ParticleEmitter#setGravityX * @since 3.0.0 * - * @param {float} value - Acceleration due to gravity, in pixels per second squared. + * @param {number} value - Acceleration due to gravity, in pixels per second squared. * * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. */ @@ -1401,7 +1401,7 @@ var ParticleEmitter = new Class({ * @method Phaser.GameObjects.Particles.ParticleEmitter#setGravityY * @since 3.0.0 * - * @param {float} value - Acceleration due to gravity, in pixels per second squared. + * @param {number} value - Acceleration due to gravity, in pixels per second squared. * * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. */ @@ -1418,8 +1418,8 @@ var ParticleEmitter = new Class({ * @method Phaser.GameObjects.Particles.ParticleEmitter#setGravity * @since 3.0.0 * - * @param {float} x - Horizontal acceleration due to gravity, in pixels per second squared. - * @param {float} y - Vertical acceleration due to gravity, in pixels per second squared. + * @param {number} x - Horizontal acceleration due to gravity, in pixels per second squared. + * @param {number} y - Vertical acceleration due to gravity, in pixels per second squared. * * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. */ @@ -1437,7 +1437,7 @@ var ParticleEmitter = new Class({ * @method Phaser.GameObjects.Particles.ParticleEmitter#setAlpha * @since 3.0.0 * - * @param {float|float[]|EmitterOpOnUpdateCallback|object} value - A value between 0 (transparent) and 1 (opaque). + * @param {number|float[]|EmitterOpOnUpdateCallback|object} value - A value between 0 (transparent) and 1 (opaque). * * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. */ @@ -1454,7 +1454,7 @@ var ParticleEmitter = new Class({ * @method Phaser.GameObjects.Particles.ParticleEmitter#setEmitterAngle * @since 3.0.0 * - * @param {float|float[]|EmitterOpOnEmitCallback|object} value - The angle of the initial velocity of emitted particles. + * @param {number|float[]|EmitterOpOnEmitCallback|object} value - The angle of the initial velocity of emitted particles. * * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. */ @@ -1471,7 +1471,7 @@ var ParticleEmitter = new Class({ * @method Phaser.GameObjects.Particles.ParticleEmitter#setAngle * @since 3.0.0 * - * @param {float|float[]|EmitterOpOnEmitCallback|object} value - The angle of the initial velocity of emitted particles. + * @param {number|float[]|EmitterOpOnEmitCallback|object} value - The angle of the initial velocity of emitted particles. * * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. */ @@ -1488,7 +1488,7 @@ var ParticleEmitter = new Class({ * @method Phaser.GameObjects.Particles.ParticleEmitter#setLifespan * @since 3.0.0 * - * @param {float|float[]|EmitterOpOnEmitCallback|object} value - The particle lifespan, in ms. + * @param {number|float[]|EmitterOpOnEmitCallback|object} value - The particle lifespan, in ms. * * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. */ @@ -1505,7 +1505,7 @@ var ParticleEmitter = new Class({ * @method Phaser.GameObjects.Particles.ParticleEmitter#setQuantity * @since 3.0.0 * - * @param {float|float[]|EmitterOpOnEmitCallback|object} quantity - The number of particles to release at each flow cycle or explosion. + * @param {number|float[]|EmitterOpOnEmitCallback|object} quantity - The number of particles to release at each flow cycle or explosion. * * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. */ @@ -1523,8 +1523,8 @@ var ParticleEmitter = new Class({ * @method Phaser.GameObjects.Particles.ParticleEmitter#setFrequency * @since 3.0.0 * - * @param {float} frequency - The time interval (>= 0) of each flow cycle, in ms; or -1 to put the emitter in explosion mode. - * @param {float|float[]|EmitterOpOnEmitCallback|object} [quantity] - The number of particles to release at each flow cycle or explosion. + * @param {number} frequency - The time interval (>= 0) of each flow cycle, in ms; or -1 to put the emitter in explosion mode. + * @param {number|float[]|EmitterOpOnEmitCallback|object} [quantity] - The number of particles to release at each flow cycle or explosion. * * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. */ @@ -1930,8 +1930,8 @@ var ParticleEmitter = new Class({ * @method Phaser.GameObjects.Particles.ParticleEmitter#flow * @since 3.0.0 * - * @param {float} frequency - The time interval (>= 0) of each flow cycle, in ms. - * @param {float|float[]|EmitterOpOnEmitCallback|object} [count=1] - The number of particles to emit at each flow cycle. + * @param {number} frequency - The time interval (>= 0) of each flow cycle, in ms. + * @param {number|float[]|EmitterOpOnEmitCallback|object} [count=1] - The number of particles to emit at each flow cycle. * * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. */ @@ -1953,8 +1953,8 @@ var ParticleEmitter = new Class({ * @since 3.0.0 * * @param {integer} count - The amount of Particles to emit. - * @param {float} x - The x coordinate to emit the Particles from. - * @param {float} y - The y coordinate to emit the Particles from. + * @param {number} x - The x coordinate to emit the Particles from. + * @param {number} y - The y coordinate to emit the Particles from. * * @return {Phaser.GameObjects.Particles.Particle} The most recently emitted Particle. */ @@ -1971,8 +1971,8 @@ var ParticleEmitter = new Class({ * @method Phaser.GameObjects.Particles.ParticleEmitter#emitParticleAt * @since 3.0.0 * - * @param {float} [x=this.x] - The x coordinate to emit the Particles from. - * @param {float} [y=this.x] - The y coordinate to emit the Particles from. + * @param {number} [x=this.x] - The x coordinate to emit the Particles from. + * @param {number} [y=this.x] - The y coordinate to emit the Particles from. * @param {integer} [count=this.quantity] - The number of Particles to emit. * * @return {Phaser.GameObjects.Particles.Particle} The most recently emitted Particle. @@ -1989,8 +1989,8 @@ var ParticleEmitter = new Class({ * @since 3.0.0 * * @param {integer} [count=this.quantity] - The number of Particles to emit. - * @param {float} [x=this.x] - The x coordinate to emit the Particles from. - * @param {float} [y=this.x] - The y coordinate to emit the Particles from. + * @param {number} [x=this.x] - The x coordinate to emit the Particles from. + * @param {number} [y=this.x] - The y coordinate to emit the Particles from. * * @return {Phaser.GameObjects.Particles.Particle} The most recently emitted Particle. * @@ -2055,7 +2055,7 @@ var ParticleEmitter = new Class({ * @since 3.0.0 * * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param {float} delta - The delta time, in ms, elapsed since the last frame. + * @param {number} delta - The delta time, in ms, elapsed since the last frame. */ preUpdate: function (time, delta) { diff --git a/src/gameobjects/quad/Quad.js b/src/gameobjects/quad/Quad.js index 41ae8d4a4..5d9e3b009 100644 --- a/src/gameobjects/quad/Quad.js +++ b/src/gameobjects/quad/Quad.js @@ -260,7 +260,7 @@ var Quad = new Class({ * The top-left alpha value of this Quad. * * @name Phaser.GameObjects.Quad#topLeftAlpha - * @type {float} + * @type {number} * @since 3.0.0 */ topLeftAlpha: { @@ -282,7 +282,7 @@ var Quad = new Class({ * The top-right alpha value of this Quad. * * @name Phaser.GameObjects.Quad#topRightAlpha - * @type {float} + * @type {number} * @since 3.0.0 */ topRightAlpha: { @@ -303,7 +303,7 @@ var Quad = new Class({ * The bottom-left alpha value of this Quad. * * @name Phaser.GameObjects.Quad#bottomLeftAlpha - * @type {float} + * @type {number} * @since 3.0.0 */ bottomLeftAlpha: { @@ -324,7 +324,7 @@ var Quad = new Class({ * The bottom-right alpha value of this Quad. * * @name Phaser.GameObjects.Quad#bottomRightAlpha - * @type {float} + * @type {number} * @since 3.0.0 */ bottomRightAlpha: { diff --git a/src/geom/circle/Circle.js b/src/geom/circle/Circle.js index 6a8e2b4d3..6c147dc35 100644 --- a/src/geom/circle/Circle.js +++ b/src/geom/circle/Circle.js @@ -104,7 +104,7 @@ var Circle = new Class({ * * @generic {Phaser.Geom.Point} O - [out,$return] * - * @param {float} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle. + * @param {number} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle. * @param {(Phaser.Geom.Point|object)} [out] - An object to store the return values in. If not given a Point object will be created. * * @return {(Phaser.Geom.Point|object)} A Point, or point-like object, containing the coordinates of the point around the circle. diff --git a/src/geom/circle/GetPoint.js b/src/geom/circle/GetPoint.js index 863736275..424847bb6 100644 --- a/src/geom/circle/GetPoint.js +++ b/src/geom/circle/GetPoint.js @@ -20,7 +20,7 @@ var Point = require('../point/Point'); * @generic {Phaser.Geom.Point} O - [out,$return] * * @param {Phaser.Geom.Circle} circle - The Circle to get the circumference point on. - * @param {float} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle. + * @param {number} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle. * @param {(Phaser.Geom.Point|object)} [out] - An object to store the return values in. If not given a Point object will be created. * * @return {(Phaser.Geom.Point|object)} A Point, or point-like object, containing the coordinates of the point around the circle. diff --git a/src/geom/ellipse/Ellipse.js b/src/geom/ellipse/Ellipse.js index 23a803a43..5dd277b94 100644 --- a/src/geom/ellipse/Ellipse.js +++ b/src/geom/ellipse/Ellipse.js @@ -106,7 +106,7 @@ var Ellipse = new Class({ * * @generic {Phaser.Geom.Point} O - [out,$return] * - * @param {float} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the ellipse. + * @param {number} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the ellipse. * @param {(Phaser.Geom.Point|object)} [out] - An object to store the return values in. If not given a Point object will be created. * * @return {(Phaser.Geom.Point|object)} A Point, or point-like object, containing the coordinates of the point around the ellipse. diff --git a/src/geom/ellipse/GetPoint.js b/src/geom/ellipse/GetPoint.js index 5392d7228..e840f1a45 100644 --- a/src/geom/ellipse/GetPoint.js +++ b/src/geom/ellipse/GetPoint.js @@ -20,7 +20,7 @@ var Point = require('../point/Point'); * @generic {Phaser.Geom.Point} O - [out,$return] * * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the circumference point on. - * @param {float} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the ellipse. + * @param {number} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the ellipse. * @param {(Phaser.Geom.Point|object)} [out] - An object to store the return values in. If not given a Point object will be created. * * @return {(Phaser.Geom.Point|object)} A Point, or point-like object, containing the coordinates of the point around the ellipse. diff --git a/src/geom/intersects/RectangleToValues.js b/src/geom/intersects/RectangleToValues.js index 2f8ef64b0..7409f15d5 100644 --- a/src/geom/intersects/RectangleToValues.js +++ b/src/geom/intersects/RectangleToValues.js @@ -15,7 +15,7 @@ * @param {number} right - [description] * @param {number} top - [description] * @param {number} bottom - [description] - * @param {float} [tolerance=0] - [description] + * @param {number} [tolerance=0] - [description] * * @return {boolean} [description] */ diff --git a/src/geom/point/Interpolate.js b/src/geom/point/Interpolate.js index a4369eb51..2b7fa5893 100644 --- a/src/geom/point/Interpolate.js +++ b/src/geom/point/Interpolate.js @@ -16,7 +16,7 @@ var Point = require('./Point'); * * @param {Phaser.Geom.Point} pointA - [description] * @param {Phaser.Geom.Point} pointB - [description] - * @param {float} [t=0] - [description] + * @param {number} [t=0] - [description] * @param {(Phaser.Geom.Point|object)} [out] - [description] * * @return {(Phaser.Geom.Point|object)} [description] diff --git a/src/geom/rectangle/GetPoint.js b/src/geom/rectangle/GetPoint.js index d272345c8..c02b57f6c 100644 --- a/src/geom/rectangle/GetPoint.js +++ b/src/geom/rectangle/GetPoint.js @@ -16,7 +16,7 @@ var Point = require('../point/Point'); * @generic {Phaser.Geom.Point} O - [out,$return] * * @param {Phaser.Geom.Rectangle} rectangle - [description] - * @param {float} position - [description] + * @param {number} position - [description] * @param {(Phaser.Geom.Point|object)} [out] - [description] * * @return {Phaser.Geom.Point} [description] diff --git a/src/geom/rectangle/Rectangle.js b/src/geom/rectangle/Rectangle.js index 37ca57448..13f714c36 100644 --- a/src/geom/rectangle/Rectangle.js +++ b/src/geom/rectangle/Rectangle.js @@ -101,7 +101,7 @@ var Rectangle = new Class({ * * @generic {Phaser.Geom.Point} O - [output,$return] * - * @param {float} position - [description] + * @param {number} position - [description] * @param {(Phaser.Geom.Point|object)} [output] - [description] * * @return {(Phaser.Geom.Point|object)} [description] diff --git a/src/geom/triangle/BuildFromPolygon.js b/src/geom/triangle/BuildFromPolygon.js index 0beaba06d..60b10cfa5 100644 --- a/src/geom/triangle/BuildFromPolygon.js +++ b/src/geom/triangle/BuildFromPolygon.js @@ -17,8 +17,8 @@ var Triangle = require('./Triangle'); * * @param {array} data - A flat array of vertice coordinates like [x0,y0, x1,y1, x2,y2, ...] * @param {array} [holes=null] - An array of hole indices if any (e.g. [5, 8] for a 12-vertice input would mean one hole with vertices 5–7 and another with 8–11). - * @param {float} [scaleX=1] - [description] - * @param {float} [scaleY=1] - [description] + * @param {number} [scaleX=1] - [description] + * @param {number} [scaleY=1] - [description] * @param {(array|Phaser.Geom.Triangle[])} [out] - [description] * * @return {(array|Phaser.Geom.Triangle[])} [description] diff --git a/src/geom/triangle/GetPoint.js b/src/geom/triangle/GetPoint.js index ce9bfa9bc..6e25faed8 100644 --- a/src/geom/triangle/GetPoint.js +++ b/src/geom/triangle/GetPoint.js @@ -17,7 +17,7 @@ var Length = require('../line/Length'); * @generic {Phaser.Geom.Point} O - [out,$return] * * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {float} position - [description] + * @param {number} position - [description] * @param {(Phaser.Geom.Point|object)} [out] - [description] * * @return {(Phaser.Geom.Point|object)} [description] diff --git a/src/geom/triangle/Triangle.js b/src/geom/triangle/Triangle.js index c63f73b8c..643c6494e 100644 --- a/src/geom/triangle/Triangle.js +++ b/src/geom/triangle/Triangle.js @@ -127,7 +127,7 @@ var Triangle = new Class({ * * @generic {Phaser.Geom.Point} O - [output,$return] * - * @param {float} position - [description] + * @param {number} position - [description] * @param {(Phaser.Geom.Point|object)} [output] - [description] * * @return {(Phaser.Geom.Point|object)} [description] diff --git a/src/input/gamepad/Axis.js b/src/input/gamepad/Axis.js index 1dc257b7e..2d4fcb616 100644 --- a/src/input/gamepad/Axis.js +++ b/src/input/gamepad/Axis.js @@ -57,7 +57,7 @@ var Axis = new Class({ * Use the method `getValue` to get a normalized value with the threshold applied. * * @name Phaser.Input.Gamepad.Axis#value - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 */ @@ -67,7 +67,7 @@ var Axis = new Class({ * Movement tolerance threshold below which axis values are ignored in `getValue`. * * @name Phaser.Input.Gamepad.Axis#threshold - * @type {float} + * @type {number} * @default 0.1 * @since 3.0.0 */ @@ -82,7 +82,7 @@ var Axis = new Class({ * @private * @since 3.0.0 * - * @param {float} value - The value of the axis movement. + * @param {number} value - The value of the axis movement. */ update: function (value) { @@ -95,7 +95,7 @@ var Axis = new Class({ * @method Phaser.Input.Gamepad.Axis#getValue * @since 3.0.0 * - * @return {float} The axis value, adjusted for the movement threshold. + * @return {number} The axis value, adjusted for the movement threshold. */ getValue: function () { diff --git a/src/input/gamepad/Button.js b/src/input/gamepad/Button.js index 78712e504..9a1682bcf 100644 --- a/src/input/gamepad/Button.js +++ b/src/input/gamepad/Button.js @@ -56,7 +56,7 @@ var Button = new Class({ * Between 0 and 1. * * @name Phaser.Input.Gamepad.Button#value - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 */ @@ -67,7 +67,7 @@ var Button = new Class({ * before a button is considered as being 'pressed'. * * @name Phaser.Input.Gamepad.Button#threshold - * @type {float} + * @type {number} * @default 1 * @since 3.0.0 */ diff --git a/src/loader/File.js b/src/loader/File.js index 5f14aa611..e2daa724e 100644 --- a/src/loader/File.js +++ b/src/loader/File.js @@ -180,7 +180,7 @@ var File = new Class({ * Only set if loading via XHR. * * @name Phaser.Loader.File#percentComplete - * @type {float} + * @type {number} * @default -1 * @since 3.0.0 */ diff --git a/src/loader/LoaderPlugin.js b/src/loader/LoaderPlugin.js index 68cf46da4..167bc9ead 100644 --- a/src/loader/LoaderPlugin.js +++ b/src/loader/LoaderPlugin.js @@ -215,7 +215,7 @@ var LoaderPlugin = new Class({ * Note that it is possible for this value to go down again if you add content to the current load queue during a load. * * @name Phaser.Loader.LoaderPlugin#progress - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 */ @@ -724,7 +724,7 @@ var LoaderPlugin = new Class({ * a file having completed loading. * * @event Phaser.Loader.LoaderPlugin#progressEvent - * @param {float} progress - The current progress of the load. A value between 0 and 1. + * @param {number} progress - The current progress of the load. A value between 0 and 1. */ /** diff --git a/src/math/DegToRad.js b/src/math/DegToRad.js index 7436d90c4..21c0e75c6 100644 --- a/src/math/DegToRad.js +++ b/src/math/DegToRad.js @@ -14,7 +14,7 @@ var CONST = require('./const'); * * @param {integer} degrees - The angle (in degrees) to convert to radians. * - * @return {float} The given angle converted to radians. + * @return {number} The given angle converted to radians. */ var DegToRad = function (degrees) { diff --git a/src/math/FloatBetween.js b/src/math/FloatBetween.js index 78943ddc4..95f938e5f 100644 --- a/src/math/FloatBetween.js +++ b/src/math/FloatBetween.js @@ -10,10 +10,10 @@ * @function Phaser.Math.FloatBetween * @since 3.0.0 * - * @param {float} min - The lower bound for the float, inclusive. - * @param {float} max - The upper bound for the float exclusive. + * @param {number} min - The lower bound for the float, inclusive. + * @param {number} max - The upper bound for the float exclusive. * - * @return {float} A random float within the given range. + * @return {number} A random float within the given range. */ var FloatBetween = function (min, max) { diff --git a/src/math/FromPercent.js b/src/math/FromPercent.js index 47793b962..6e7d61465 100644 --- a/src/math/FromPercent.js +++ b/src/math/FromPercent.js @@ -12,7 +12,7 @@ var Clamp = require('./Clamp'); * @function Phaser.Math.FromPercent * @since 3.0.0 * - * @param {float} percent - A value between 0 and 1 representing the percentage. + * @param {number} percent - A value between 0 and 1 representing the percentage. * @param {number} min - The minimum value. * @param {number} [max] - The maximum value. * diff --git a/src/math/Linear.js b/src/math/Linear.js index 5ef9ced14..b891f6803 100644 --- a/src/math/Linear.js +++ b/src/math/Linear.js @@ -12,7 +12,7 @@ * * @param {number} p0 - The first point. * @param {number} p1 - The second point. - * @param {float} t - The percentage between p0 and p1 to return, represented as a number between 0 and 1. + * @param {number} t - The percentage between p0 and p1 to return, represented as a number between 0 and 1. * * @return {number} The step t% of the way between p0 and p1. */ diff --git a/src/math/Matrix4.js b/src/math/Matrix4.js index 202bfebd8..e4338ec17 100644 --- a/src/math/Matrix4.js +++ b/src/math/Matrix4.js @@ -666,7 +666,7 @@ var Matrix4 = new Class({ * @since 3.0.0 * * @param {(Phaser.Math.Vector3|Phaser.Math.Vector4)} axis - The rotation axis. - * @param {float} angle - The rotation angle in radians. + * @param {number} angle - The rotation angle in radians. * * @return {Phaser.Math.Matrix4} This Matrix4. */ @@ -699,7 +699,7 @@ var Matrix4 = new Class({ * @method Phaser.Math.Matrix4#rotate * @since 3.0.0 * - * @param {float} rad - The angle in radians to rotate by. + * @param {number} rad - The angle in radians to rotate by. * @param {Phaser.Math.Vector3} axis - The axis to rotate upon. * * @return {Phaser.Math.Matrix4} This Matrix4. @@ -777,7 +777,7 @@ var Matrix4 = new Class({ * @method Phaser.Math.Matrix4#rotateX * @since 3.0.0 * - * @param {float} rad - The angle in radians to rotate by. + * @param {number} rad - The angle in radians to rotate by. * * @return {Phaser.Math.Matrix4} This Matrix4. */ @@ -816,7 +816,7 @@ var Matrix4 = new Class({ * @method Phaser.Math.Matrix4#rotateY * @since 3.0.0 * - * @param {float} rad - The angle to rotate by, in radians. + * @param {number} rad - The angle to rotate by, in radians. * * @return {Phaser.Math.Matrix4} This Matrix4. */ @@ -855,7 +855,7 @@ var Matrix4 = new Class({ * @method Phaser.Math.Matrix4#rotateZ * @since 3.0.0 * - * @param {float} rad - The angle to rotate by, in radians. + * @param {number} rad - The angle to rotate by, in radians. * * @return {Phaser.Math.Matrix4} This Matrix4. */ diff --git a/src/math/Percent.js b/src/math/Percent.js index 5e1db799f..15421e701 100644 --- a/src/math/Percent.js +++ b/src/math/Percent.js @@ -18,7 +18,7 @@ * @param {number} [max] - The maximum value. * @param {number} [upperMax] - The mid-way point in the range that represents 100%. * - * @return {float} A value between 0 and 1 representing the percentage. + * @return {number} A value between 0 and 1 representing the percentage. */ var Percent = function (value, min, max, upperMax) { diff --git a/src/math/RadToDeg.js b/src/math/RadToDeg.js index c991e15f4..1bde46d4c 100644 --- a/src/math/RadToDeg.js +++ b/src/math/RadToDeg.js @@ -12,7 +12,7 @@ var CONST = require('./const'); * @function Phaser.Math.RadToDeg * @since 3.0.0 * - * @param {float} radians - The angle in radians to convert ot degrees. + * @param {number} radians - The angle in radians to convert ot degrees. * * @return {integer} The given angle converted to degrees. */ diff --git a/src/math/RandomXY.js b/src/math/RandomXY.js index d58bf5df1..9c523c75c 100644 --- a/src/math/RandomXY.js +++ b/src/math/RandomXY.js @@ -15,7 +15,7 @@ * @since 3.0.0 * * @param {Phaser.Math.Vector2} vector - The Vector to compute random values for. - * @param {float} [scale=1] - The scale of the random values. + * @param {number} [scale=1] - The scale of the random values. * * @return {Phaser.Math.Vector2} The given Vector. */ diff --git a/src/math/RandomXYZW.js b/src/math/RandomXYZW.js index bf44c29b0..2a6e61e6d 100644 --- a/src/math/RandomXYZW.js +++ b/src/math/RandomXYZW.js @@ -11,7 +11,7 @@ * @since 3.0.0 * * @param {Phaser.Math.Vector4} vec4 - The Vector to compute random values for. - * @param {float} [scale=1] - The scale of the random values. + * @param {number} [scale=1] - The scale of the random values. * * @return {Phaser.Math.Vector4} The given Vector. */ diff --git a/src/math/Vector2.js b/src/math/Vector2.js index 5fb099ccc..54aa8efd7 100644 --- a/src/math/Vector2.js +++ b/src/math/Vector2.js @@ -162,8 +162,8 @@ var Vector2 = new Class({ * @method Phaser.Math.Vector2#setToPolar * @since 3.0.0 * - * @param {float} azimuth - The angular coordinate, in radians. - * @param {float} [radius=1] - The radial coordinate (length). + * @param {number} azimuth - The angular coordinate, in radians. + * @param {number} [radius=1] - The radial coordinate (length). * * @return {Phaser.Math.Vector2} This Vector2. */ diff --git a/src/math/easing/elastic/In.js b/src/math/easing/elastic/In.js index ea1a4d28b..8e095c437 100644 --- a/src/math/easing/elastic/In.js +++ b/src/math/easing/elastic/In.js @@ -11,8 +11,8 @@ * @since 3.0.0 * * @param {number} v - The value to be tweened. - * @param {float} [amplitude=0.1] - The amplitude of the elastic ease. - * @param {float} [period=0.1] - [description] + * @param {number} [amplitude=0.1] - The amplitude of the elastic ease. + * @param {number} [period=0.1] - [description] * * @return {number} The tweened value. */ diff --git a/src/math/easing/elastic/InOut.js b/src/math/easing/elastic/InOut.js index a29849c4d..3de98c6f1 100644 --- a/src/math/easing/elastic/InOut.js +++ b/src/math/easing/elastic/InOut.js @@ -11,8 +11,8 @@ * @since 3.0.0 * * @param {number} v - The value to be tweened. - * @param {float} [amplitude=0.1] - The amplitude of the elastic ease. - * @param {float} [period=0.1] - [description] + * @param {number} [amplitude=0.1] - The amplitude of the elastic ease. + * @param {number} [period=0.1] - [description] * * @return {number} The tweened value. */ diff --git a/src/math/easing/elastic/Out.js b/src/math/easing/elastic/Out.js index 2b33921ab..c30596d3f 100644 --- a/src/math/easing/elastic/Out.js +++ b/src/math/easing/elastic/Out.js @@ -11,8 +11,8 @@ * @since 3.0.0 * * @param {number} v - The value to be tweened. - * @param {float} [amplitude=0.1] - The amplitude of the elastic ease. - * @param {float} [period=0.1] - [description] + * @param {number} [amplitude=0.1] - The amplitude of the elastic ease. + * @param {number} [period=0.1] - [description] * * @return {number} The tweened value. */ diff --git a/src/math/fuzzy/Ceil.js b/src/math/fuzzy/Ceil.js index 96f4df163..dd5921bae 100644 --- a/src/math/fuzzy/Ceil.js +++ b/src/math/fuzzy/Ceil.js @@ -11,7 +11,7 @@ * @since 3.0.0 * * @param {number} value - The value. - * @param {float} [epsilon=0.0001] - The epsilon. + * @param {number} [epsilon=0.0001] - The epsilon. * * @return {number} The fuzzy ceiling of the value. */ diff --git a/src/math/fuzzy/Equal.js b/src/math/fuzzy/Equal.js index 67d2d362b..cbfd7cd6d 100644 --- a/src/math/fuzzy/Equal.js +++ b/src/math/fuzzy/Equal.js @@ -14,7 +14,7 @@ * * @param {number} a - The first value. * @param {number} b - The second value. - * @param {float} [epsilon=0.0001] - The epsilon. + * @param {number} [epsilon=0.0001] - The epsilon. * * @return {boolean} `true` if the values are fuzzily equal, otherwise `false`. */ diff --git a/src/math/fuzzy/Floor.js b/src/math/fuzzy/Floor.js index fb662a110..a9f3e7582 100644 --- a/src/math/fuzzy/Floor.js +++ b/src/math/fuzzy/Floor.js @@ -11,7 +11,7 @@ * @since 3.0.0 * * @param {number} value - The value. - * @param {float} [epsilon=0.0001] - The epsilon. + * @param {number} [epsilon=0.0001] - The epsilon. * * @return {number} The floor of the value. */ diff --git a/src/math/fuzzy/GreaterThan.js b/src/math/fuzzy/GreaterThan.js index cf28754df..f67c97539 100644 --- a/src/math/fuzzy/GreaterThan.js +++ b/src/math/fuzzy/GreaterThan.js @@ -14,7 +14,7 @@ * * @param {number} a - The first value. * @param {number} b - The second value. - * @param {float} [epsilon=0.0001] - The epsilon. + * @param {number} [epsilon=0.0001] - The epsilon. * * @return {boolean} `true` if `a` is fuzzily greater than than `b`, otherwise `false`. */ diff --git a/src/math/fuzzy/LessThan.js b/src/math/fuzzy/LessThan.js index f03d8cf1d..22810fe95 100644 --- a/src/math/fuzzy/LessThan.js +++ b/src/math/fuzzy/LessThan.js @@ -14,7 +14,7 @@ * * @param {number} a - The first value. * @param {number} b - The second value. - * @param {float} [epsilon=0.0001] - The epsilon. + * @param {number} [epsilon=0.0001] - The epsilon. * * @return {boolean} `true` if `a` is fuzzily less than `b`, otherwise `false`. */ diff --git a/src/math/interpolation/CubicBezierInterpolation.js b/src/math/interpolation/CubicBezierInterpolation.js index 07721a3db..1bf717c02 100644 --- a/src/math/interpolation/CubicBezierInterpolation.js +++ b/src/math/interpolation/CubicBezierInterpolation.js @@ -41,7 +41,7 @@ function P3 (t, p) * @function Phaser.Math.Interpolation.CubicBezier * @since 3.0.0 * - * @param {float} t - The percentage of interpolation, between 0 and 1. + * @param {number} t - The percentage of interpolation, between 0 and 1. * @param {number} p0 - The start point. * @param {number} p1 - The first control point. * @param {number} p2 - The second control point. diff --git a/src/math/interpolation/QuadraticBezierInterpolation.js b/src/math/interpolation/QuadraticBezierInterpolation.js index c9a67eb2b..177097ee7 100644 --- a/src/math/interpolation/QuadraticBezierInterpolation.js +++ b/src/math/interpolation/QuadraticBezierInterpolation.js @@ -33,7 +33,7 @@ function P2 (t, p) * @function Phaser.Math.Interpolation.QuadraticBezier * @since 3.2.0 * - * @param {float} t - The percentage of interpolation, between 0 and 1. + * @param {number} t - The percentage of interpolation, between 0 and 1. * @param {number} p0 - The start point. * @param {number} p1 - The control point. * @param {number} p2 - The end point. diff --git a/src/physics/impact/World.js b/src/physics/impact/World.js index cc7e70a9e..04af7557a 100644 --- a/src/physics/impact/World.js +++ b/src/physics/impact/World.js @@ -22,7 +22,7 @@ var TYPE = require('./TYPE'); * @property {number} [gravity=0] - [description] * @property {number} [cellSize=64] - [description] * @property {number} [timeScale=1] - [description] - * @property {float} [maxStep=0.05] - [description] + * @property {number} [maxStep=0.05] - [description] * @property {boolean} [debug=false] - [description] * @property {number} [maxVelocity=100] - [description] * @property {boolean} [debugShowBody=true] - [description] @@ -145,7 +145,7 @@ var World = new Class({ * [description] * * @name Phaser.Physics.Impact.World#timeScale - * @type {float} + * @type {number} * @default 1 * @since 3.0.0 */ diff --git a/src/physics/matter-js/components/Bounce.js b/src/physics/matter-js/components/Bounce.js index 3851a5ea7..9ada1efaf 100644 --- a/src/physics/matter-js/components/Bounce.js +++ b/src/physics/matter-js/components/Bounce.js @@ -18,7 +18,7 @@ var Bounce = { * @method Phaser.Physics.Matter.Components.Bounce#setBounce * @since 3.0.0 * - * @param {float} value - [description] + * @param {number} value - [description] * * @return {Phaser.GameObjects.GameObject} This Game Object. */ diff --git a/src/renderer/canvas/CanvasRenderer.js b/src/renderer/canvas/CanvasRenderer.js index a15672c8f..a967f9cb2 100644 --- a/src/renderer/canvas/CanvasRenderer.js +++ b/src/renderer/canvas/CanvasRenderer.js @@ -324,9 +324,9 @@ var CanvasRenderer = new Class({ * @method Phaser.Renderer.Canvas.CanvasRenderer#setAlpha * @since 3.0.0 * - * @param {float} alpha - [description] + * @param {number} alpha - [description] * - * @return {float} [description] + * @return {number} [description] */ setAlpha: function (alpha) { @@ -375,7 +375,7 @@ var CanvasRenderer = new Class({ * * @param {Phaser.Scene} scene - [description] * @param {Phaser.GameObjects.DisplayList} children - [description] - * @param {float} interpolationPercentage - [description] + * @param {number} interpolationPercentage - [description] * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] */ render: function (scene, children, interpolationPercentage, camera) diff --git a/src/renderer/snapshot/CanvasSnapshot.js b/src/renderer/snapshot/CanvasSnapshot.js index 9098a15a4..8c5d06ff3 100644 --- a/src/renderer/snapshot/CanvasSnapshot.js +++ b/src/renderer/snapshot/CanvasSnapshot.js @@ -12,7 +12,7 @@ * * @param {HTMLCanvasElement} canvas - [description] * @param {string} [type='image/png'] - [description] - * @param {float} [encoderOptions=0.92] - [description] + * @param {number} [encoderOptions=0.92] - [description] * * @return {HTMLImageElement} [description] */ diff --git a/src/renderer/snapshot/WebGLSnapshot.js b/src/renderer/snapshot/WebGLSnapshot.js index 2aa5f0030..2d28e951a 100644 --- a/src/renderer/snapshot/WebGLSnapshot.js +++ b/src/renderer/snapshot/WebGLSnapshot.js @@ -12,7 +12,7 @@ * * @param {HTMLCanvasElement} sourceCanvas - [description] * @param {string} [type='image/png'] - [description] - * @param {float} [encoderOptions=0.92] - [description] + * @param {number} [encoderOptions=0.92] - [description] * * @return {HTMLImageElement} [description] */ diff --git a/src/renderer/webgl/WebGLPipeline.js b/src/renderer/webgl/WebGLPipeline.js index c8ae0f425..b15259eff 100644 --- a/src/renderer/webgl/WebGLPipeline.js +++ b/src/renderer/webgl/WebGLPipeline.js @@ -459,7 +459,7 @@ var WebGLPipeline = new Class({ * @since 3.2.0 * * @param {string} name - [description] - * @param {float} x - [description] + * @param {number} x - [description] * * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] */ @@ -476,8 +476,8 @@ var WebGLPipeline = new Class({ * @since 3.2.0 * * @param {string} name - [description] - * @param {float} x - [description] - * @param {float} y - [description] + * @param {number} x - [description] + * @param {number} y - [description] * * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] */ @@ -495,9 +495,9 @@ var WebGLPipeline = new Class({ * @since 3.2.0 * * @param {string} name - [description] - * @param {float} x - [description] - * @param {float} y - [description] - * @param {float} z - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} z - [description] * * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] */ @@ -515,10 +515,10 @@ var WebGLPipeline = new Class({ * @since 3.2.0 * * @param {string} name - Name of the uniform - * @param {float} x - X component of the uniform - * @param {float} y - Y component of the uniform - * @param {float} z - Z component of the uniform - * @param {float} w - W component of the uniform + * @param {number} x - X component of the uniform + * @param {number} y - Y component of the uniform + * @param {number} z - Z component of the uniform + * @param {number} w - W component of the uniform * * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] */ diff --git a/src/renderer/webgl/WebGLRenderer.js b/src/renderer/webgl/WebGLRenderer.js index b18049581..5da8c6210 100644 --- a/src/renderer/webgl/WebGLRenderer.js +++ b/src/renderer/webgl/WebGLRenderer.js @@ -29,7 +29,7 @@ var TextureTintPipeline = require('./pipelines/TextureTintPipeline'); * * @property {SnapshotCallback} callback - [description] * @property {string} type - [description] - * @property {float} encoder - [description] + * @property {number} encoder - [description] */ /** @@ -1607,7 +1607,7 @@ var WebGLRenderer = new Class({ * * @param {SnapshotCallback} callback - [description] * @param {string} type - [description] - * @param {float} encoderOptions - [description] + * @param {number} encoderOptions - [description] * * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] */ @@ -1695,7 +1695,7 @@ var WebGLRenderer = new Class({ * * @param {WebGLProgram} program - [description] * @param {string} name - [description] - * @param {float} x - [description] + * @param {number} x - [description] * * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] */ @@ -1716,8 +1716,8 @@ var WebGLRenderer = new Class({ * * @param {WebGLProgram} program - [description] * @param {string} name - [description] - * @param {float} x - [description] - * @param {float} y - [description] + * @param {number} x - [description] + * @param {number} y - [description] * * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] */ @@ -1738,9 +1738,9 @@ var WebGLRenderer = new Class({ * * @param {WebGLProgram} program - [description] * @param {string} name - [description] - * @param {float} x - [description] - * @param {float} y - [description] - * @param {float} z - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} z - [description] * * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] */ @@ -1761,10 +1761,10 @@ var WebGLRenderer = new Class({ * * @param {WebGLProgram} program - Target program * @param {string} name - Name of the uniform - * @param {float} x - X component - * @param {float} y - Y component - * @param {float} z - Z component - * @param {float} w - W component + * @param {number} x - X component + * @param {number} y - Y component + * @param {number} z - Z component + * @param {number} w - W component * * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] */ diff --git a/src/renderer/webgl/pipelines/FlatTintPipeline.js b/src/renderer/webgl/pipelines/FlatTintPipeline.js index 9857eff47..6c18427ec 100644 --- a/src/renderer/webgl/pipelines/FlatTintPipeline.js +++ b/src/renderer/webgl/pipelines/FlatTintPipeline.js @@ -187,23 +187,23 @@ var FlatTintPipeline = new Class({ * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchFillRect * @since 3.0.0 * - * @param {float} srcX - Graphics horizontal component for translation - * @param {float} srcY - Graphics vertical component for translation - * @param {float} srcScaleX - Graphics horizontal component for scale - * @param {float} srcScaleY - Graphics vertical component for scale - * @param {float} srcRotation - Graphics rotation - * @param {float} x - Horiztonal top left coordinate of the rectangle - * @param {float} y - Vertical top left coordinate of the rectangle - * @param {float} width - Width of the rectangle - * @param {float} height - Height of the rectangle + * @param {number} srcX - Graphics horizontal component for translation + * @param {number} srcY - Graphics vertical component for translation + * @param {number} srcScaleX - Graphics horizontal component for scale + * @param {number} srcScaleY - Graphics vertical component for scale + * @param {number} srcRotation - Graphics rotation + * @param {number} x - Horiztonal top left coordinate of the rectangle + * @param {number} y - Vertical top left coordinate of the rectangle + * @param {number} width - Width of the rectangle + * @param {number} height - Height of the rectangle * @param {integer} fillColor - RGB color packed as a uint - * @param {float} fillAlpha - Alpha represented as float - * @param {float} a1 - Matrix stack top a component - * @param {float} b1 - Matrix stack top b component - * @param {float} c1 - Matrix stack top c component - * @param {float} d1 - Matrix stack top d component - * @param {float} e1 - Matrix stack top e component - * @param {float} f1 - Matrix stack top f component + * @param {number} fillAlpha - Alpha represented as float + * @param {number} a1 - Matrix stack top a component + * @param {number} b1 - Matrix stack top b component + * @param {number} c1 - Matrix stack top c component + * @param {number} d1 - Matrix stack top d component + * @param {number} e1 - Matrix stack top e component + * @param {number} f1 - Matrix stack top f component * @param {Float32Array} currentMatrix - Parent matrix, generally used by containers */ batchFillRect: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, x, y, width, height, fillColor, fillAlpha, a1, b1, c1, d1, e1, f1, currentMatrix) @@ -270,25 +270,25 @@ var FlatTintPipeline = new Class({ * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchFillTriangle * @since 3.0.0 * - * @param {float} srcX - Graphics horizontal component for translation - * @param {float} srcY - Graphics vertical component for translation - * @param {float} srcScaleX - Graphics horizontal component for scale - * @param {float} srcScaleY - Graphics vertical component for scale - * @param {float} srcRotation - Graphics rotation - * @param {float} x0 - Point 0 x coordinate - * @param {float} y0 - Point 0 y coordinate - * @param {float} x1 - Point 1 x coordinate - * @param {float} y1 - Point 1 y coordinate - * @param {float} x2 - Point 2 x coordinate - * @param {float} y2 - Point 2 y coordinate + * @param {number} srcX - Graphics horizontal component for translation + * @param {number} srcY - Graphics vertical component for translation + * @param {number} srcScaleX - Graphics horizontal component for scale + * @param {number} srcScaleY - Graphics vertical component for scale + * @param {number} srcRotation - Graphics rotation + * @param {number} x0 - Point 0 x coordinate + * @param {number} y0 - Point 0 y coordinate + * @param {number} x1 - Point 1 x coordinate + * @param {number} y1 - Point 1 y coordinate + * @param {number} x2 - Point 2 x coordinate + * @param {number} y2 - Point 2 y coordinate * @param {integer} fillColor - RGB color packed as a uint - * @param {float} fillAlpha - Alpha represented as float - * @param {float} a1 - Matrix stack top a component - * @param {float} b1 - Matrix stack top b component - * @param {float} c1 - Matrix stack top c component - * @param {float} d1 - Matrix stack top d component - * @param {float} e1 - Matrix stack top e component - * @param {float} f1 - Matrix stack top f component + * @param {number} fillAlpha - Alpha represented as float + * @param {number} a1 - Matrix stack top a component + * @param {number} b1 - Matrix stack top b component + * @param {number} c1 - Matrix stack top c component + * @param {number} d1 - Matrix stack top d component + * @param {number} e1 - Matrix stack top e component + * @param {number} f1 - Matrix stack top f component * @param {Float32Array} currentMatrix - Parent matrix, generally used by containers */ batchFillTriangle: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, x0, y0, x1, y1, x2, y2, fillColor, fillAlpha, a1, b1, c1, d1, e1, f1, currentMatrix) @@ -342,26 +342,26 @@ var FlatTintPipeline = new Class({ * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchStrokeTriangle * @since 3.0.0 * - * @param {float} srcX - Graphics horizontal component for translation - * @param {float} srcY - Graphics vertical component for translation - * @param {float} srcScaleX - Graphics horizontal component for scale - * @param {float} srcScaleY - Graphics vertical component for scale - * @param {float} srcRotation - Graphics rotation - * @param {float} x0 - [description] - * @param {float} y0 - [description] - * @param {float} x1 - [description] - * @param {float} y1 - [description] - * @param {float} x2 - [description] - * @param {float} y2 - [description] - * @param {float} lineWidth - Size of the line as a float value + * @param {number} srcX - Graphics horizontal component for translation + * @param {number} srcY - Graphics vertical component for translation + * @param {number} srcScaleX - Graphics horizontal component for scale + * @param {number} srcScaleY - Graphics vertical component for scale + * @param {number} srcRotation - Graphics rotation + * @param {number} x0 - [description] + * @param {number} y0 - [description] + * @param {number} x1 - [description] + * @param {number} y1 - [description] + * @param {number} x2 - [description] + * @param {number} y2 - [description] + * @param {number} lineWidth - Size of the line as a float value * @param {integer} lineColor - RGB color packed as a uint - * @param {float} lineAlpha - Alpha represented as float - * @param {float} a - Matrix stack top a component - * @param {float} b - Matrix stack top b component - * @param {float} c - Matrix stack top c component - * @param {float} d - Matrix stack top d component - * @param {float} e - Matrix stack top e component - * @param {float} f - Matrix stack top f component + * @param {number} lineAlpha - Alpha represented as float + * @param {number} a - Matrix stack top a component + * @param {number} b - Matrix stack top b component + * @param {number} c - Matrix stack top c component + * @param {number} d - Matrix stack top d component + * @param {number} e - Matrix stack top e component + * @param {number} f - Matrix stack top f component * @param {Float32Array} currentMatrix - Parent matrix, generally used by containers */ batchStrokeTriangle: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, x0, y0, x1, y1, x2, y2, lineWidth, lineColor, lineAlpha, a, b, c, d, e, f, currentMatrix) @@ -404,20 +404,20 @@ var FlatTintPipeline = new Class({ * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchFillPath * @since 3.0.0 * - * @param {float} srcX - Graphics horizontal component for translation - * @param {float} srcY - Graphics vertical component for translation - * @param {float} srcScaleX - Graphics horizontal component for scale - * @param {float} srcScaleY - Graphics vertical component for scale - * @param {float} srcRotation - Graphics rotation - * @param {float} path - Collection of points that represent the path + * @param {number} srcX - Graphics horizontal component for translation + * @param {number} srcY - Graphics vertical component for translation + * @param {number} srcScaleX - Graphics horizontal component for scale + * @param {number} srcScaleY - Graphics vertical component for scale + * @param {number} srcRotation - Graphics rotation + * @param {number} path - Collection of points that represent the path * @param {integer} fillColor - RGB color packed as a uint - * @param {float} fillAlpha - Alpha represented as float - * @param {float} a1 - Matrix stack top a component - * @param {float} b1 - Matrix stack top b component - * @param {float} c1 - Matrix stack top c component - * @param {float} d1 - Matrix stack top d component - * @param {float} e1 - Matrix stack top e component - * @param {float} f1 - Matrix stack top f component + * @param {number} fillAlpha - Alpha represented as float + * @param {number} a1 - Matrix stack top a component + * @param {number} b1 - Matrix stack top b component + * @param {number} c1 - Matrix stack top c component + * @param {number} d1 - Matrix stack top d component + * @param {number} e1 - Matrix stack top e component + * @param {number} f1 - Matrix stack top f component * @param {Float32Array} currentMatrix - Parent matrix, generally used by containers */ batchFillPath: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, path, fillColor, fillAlpha, a1, b1, c1, d1, e1, f1, currentMatrix) @@ -506,21 +506,21 @@ var FlatTintPipeline = new Class({ * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchStrokePath * @since 3.0.0 * - * @param {float} srcX - Graphics horizontal component for translation - * @param {float} srcY - Graphics vertical component for translation - * @param {float} srcScaleX - Graphics horizontal component for scale - * @param {float} srcScaleY - Graphics vertical component for scale - * @param {float} srcRotation - Graphics rotation + * @param {number} srcX - Graphics horizontal component for translation + * @param {number} srcY - Graphics vertical component for translation + * @param {number} srcScaleX - Graphics horizontal component for scale + * @param {number} srcScaleY - Graphics vertical component for scale + * @param {number} srcRotation - Graphics rotation * @param {array} path - [description] - * @param {float} lineWidth - [description] + * @param {number} lineWidth - [description] * @param {integer} lineColor - RGB color packed as a uint - * @param {float} lineAlpha - Alpha represented as float - * @param {float} a - Matrix stack top a component - * @param {float} b - Matrix stack top b component - * @param {float} c - Matrix stack top c component - * @param {float} d - Matrix stack top d component - * @param {float} e - Matrix stack top e component - * @param {float} f - Matrix stack top f component + * @param {number} lineAlpha - Alpha represented as float + * @param {number} a - Matrix stack top a component + * @param {number} b - Matrix stack top b component + * @param {number} c - Matrix stack top c component + * @param {number} d - Matrix stack top d component + * @param {number} e - Matrix stack top e component + * @param {number} f - Matrix stack top f component * @param {boolean} isLastPath - Indicates if the path should be closed * @param {Float32Array} currentMatrix - Parent matrix, generally used by containers */ @@ -599,26 +599,26 @@ var FlatTintPipeline = new Class({ * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchLine * @since 3.0.0 * - * @param {float} srcX - Graphics horizontal component for translation - * @param {float} srcY - Graphics vertical component for translation - * @param {float} srcScaleX - Graphics horizontal component for scale - * @param {float} srcScaleY - Graphics vertical component for scale - * @param {float} srcRotation - Graphics rotation - * @param {float} ax - X coordinate to the start of the line - * @param {float} ay - Y coordinate to the start of the line - * @param {float} bx - X coordinate to the end of the line - * @param {float} by - Y coordinate to the end of the line - * @param {float} aLineWidth - Width of the start of the line - * @param {float} bLineWidth - Width of the end of the line + * @param {number} srcX - Graphics horizontal component for translation + * @param {number} srcY - Graphics vertical component for translation + * @param {number} srcScaleX - Graphics horizontal component for scale + * @param {number} srcScaleY - Graphics vertical component for scale + * @param {number} srcRotation - Graphics rotation + * @param {number} ax - X coordinate to the start of the line + * @param {number} ay - Y coordinate to the start of the line + * @param {number} bx - X coordinate to the end of the line + * @param {number} by - Y coordinate to the end of the line + * @param {number} aLineWidth - Width of the start of the line + * @param {number} bLineWidth - Width of the end of the line * @param {integer} aLineColor - RGB color packed as a uint * @param {integer} bLineColor - RGB color packed as a uint - * @param {float} lineAlpha - Alpha represented as float - * @param {float} a1 - Matrix stack top a component - * @param {float} b1 - Matrix stack top b component - * @param {float} c1 - Matrix stack top c component - * @param {float} d1 - Matrix stack top d component - * @param {float} e1 - Matrix stack top e component - * @param {float} f1 - Matrix stack top f component + * @param {number} lineAlpha - Alpha represented as float + * @param {number} a1 - Matrix stack top a component + * @param {number} b1 - Matrix stack top b component + * @param {number} c1 - Matrix stack top c component + * @param {number} d1 - Matrix stack top d component + * @param {number} e1 - Matrix stack top e component + * @param {number} f1 - Matrix stack top f component * @param {Float32Array} currentMatrix - Parent matrix, generally used by containers */ batchLine: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, ax, ay, bx, by, aLineWidth, bLineWidth, aLineColor, bLineColor, lineAlpha, a1, b1, c1, d1, e1, f1, currentMatrix) diff --git a/src/renderer/webgl/pipelines/TextureTintPipeline.js b/src/renderer/webgl/pipelines/TextureTintPipeline.js index 33f290aa3..0b1d60f67 100644 --- a/src/renderer/webgl/pipelines/TextureTintPipeline.js +++ b/src/renderer/webgl/pipelines/TextureTintPipeline.js @@ -1847,29 +1847,29 @@ var TextureTintPipeline = new Class({ * @param {WebGLTexture} texture - Raw WebGLTexture associated with the quad * @param {integer} textureWidth - Real texture width * @param {integer} textureHeight - Real texture height - * @param {float} srcX - X coordinate of the quad - * @param {float} srcY - Y coordinate of the quad - * @param {float} srcWidth - Width of the quad - * @param {float} srcHeight - Height of the quad - * @param {float} scaleX - X component of scale - * @param {float} scaleY - Y component of scale - * @param {float} rotation - Rotation of the quad + * @param {number} srcX - X coordinate of the quad + * @param {number} srcY - Y coordinate of the quad + * @param {number} srcWidth - Width of the quad + * @param {number} srcHeight - Height of the quad + * @param {number} scaleX - X component of scale + * @param {number} scaleY - Y component of scale + * @param {number} rotation - Rotation of the quad * @param {boolean} flipX - Indicates if the quad is horizontally flipped * @param {boolean} flipY - Indicates if the quad is vertically flipped - * @param {float} scrollFactorX - By which factor is the quad affected by the camera horizontal scroll - * @param {float} scrollFactorY - By which factor is the quad effected by the camera vertical scroll - * @param {float} displayOriginX - Horizontal origin in pixels - * @param {float} displayOriginY - Vertical origin in pixels - * @param {float} frameX - X coordinate of the texture frame - * @param {float} frameY - Y coordinate of the texture frame - * @param {float} frameWidth - Width of the texture frame - * @param {float} frameHeight - Height of the texture frame + * @param {number} scrollFactorX - By which factor is the quad affected by the camera horizontal scroll + * @param {number} scrollFactorY - By which factor is the quad effected by the camera vertical scroll + * @param {number} displayOriginX - Horizontal origin in pixels + * @param {number} displayOriginY - Vertical origin in pixels + * @param {number} frameX - X coordinate of the texture frame + * @param {number} frameY - Y coordinate of the texture frame + * @param {number} frameWidth - Width of the texture frame + * @param {number} frameHeight - Height of the texture frame * @param {integer} tintTL - Tint for top left * @param {integer} tintTR - Tint for top right * @param {integer} tintBL - Tint for bottom left * @param {integer} tintBR - Tint for bottom right - * @param {float} uOffset - Horizontal offset on texture coordinate - * @param {float} vOffset - Vertical offset on texture coordinate + * @param {number} uOffset - Horizontal offset on texture coordinate + * @param {number} vOffset - Vertical offset on texture coordinate * @param {Phaser.Cameras.Scene2D.Camera} camera - Current used camera * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - Parent container */ diff --git a/src/scene/ScenePlugin.js b/src/scene/ScenePlugin.js index 5597dbc2b..103aa4be8 100644 --- a/src/scene/ScenePlugin.js +++ b/src/scene/ScenePlugin.js @@ -77,7 +77,7 @@ var ScenePlugin = new Class({ * the current percentage of the transition progress, between 0 and 1. * * @name Phaser.Scenes.ScenePlugin#transitionProgress - * @type {float} + * @type {number} * @since 3.5.0 */ this.transitionProgress = 0; diff --git a/src/tilemaps/mapdata/LayerData.js b/src/tilemaps/mapdata/LayerData.js index 37a6ef966..f5a6c3c6e 100644 --- a/src/tilemaps/mapdata/LayerData.js +++ b/src/tilemaps/mapdata/LayerData.js @@ -131,7 +131,7 @@ var LayerData = new Class({ * [description] * * @name Phaser.Tilemaps.LayerData#alpha - * @type {float} + * @type {number} * @since 3.0.0 */ this.alpha = GetFastValue(config, 'alpha', 1); diff --git a/src/time/Clock.js b/src/time/Clock.js index 00249b317..325191380 100644 --- a/src/time/Clock.js +++ b/src/time/Clock.js @@ -59,7 +59,7 @@ var Clock = new Class({ * [description] * * @name Phaser.Time.Clock#timeScale - * @type {float} + * @type {number} * @default 1 * @since 3.0.0 */ diff --git a/src/tweens/TweenManager.js b/src/tweens/TweenManager.js index f3e358699..32ec7feaf 100644 --- a/src/tweens/TweenManager.js +++ b/src/tweens/TweenManager.js @@ -615,7 +615,7 @@ var TweenManager = new Class({ * @method Phaser.Tweens.TweenManager#setGlobalTimeScale * @since 3.0.0 * - * @param {float} value - [description] + * @param {number} value - [description] * * @return {Phaser.Tweens.TweenManager} [description] */ diff --git a/src/tweens/tween/Tween.js b/src/tweens/tween/Tween.js index 30a51b711..92845ac41 100644 --- a/src/tweens/tween/Tween.js +++ b/src/tweens/tween/Tween.js @@ -752,7 +752,7 @@ var Tween = new Class({ * @method Phaser.Tweens.Tween#seek * @since 3.0.0 * - * @param {float} toPosition - A value between 0 and 1. + * @param {number} toPosition - A value between 0 and 1. */ seek: function (toPosition) { @@ -885,7 +885,7 @@ var Tween = new Class({ * @method Phaser.Tweens.Tween#stop * @since 3.0.0 * - * @param {float} [resetTo] - A value between 0 and 1. + * @param {number} [resetTo] - A value between 0 and 1. */ stop: function (resetTo) { From bb29f0cdfce053b339802c3747fa4ee79bdec036 Mon Sep 17 00:00:00 2001 From: samme Date: Tue, 26 Jun 2018 15:57:49 -0700 Subject: [PATCH 29/48] Fix `context` argument wrongly passed to callback --- src/utils/array/Each.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/array/Each.js b/src/utils/array/Each.js index 49ecded23..857251cf2 100644 --- a/src/utils/array/Each.js +++ b/src/utils/array/Each.js @@ -22,7 +22,7 @@ var Each = function (array, callback, context) var i; var args = [ null ]; - for (i = 2; i < arguments.length; i++) + for (i = 3; i < arguments.length; i++) { args.push(arguments[i]); } From 703f33834846d62ff4670ee7b66cfc1f31bf3fbf Mon Sep 17 00:00:00 2001 From: samme Date: Tue, 26 Jun 2018 15:58:51 -0700 Subject: [PATCH 30/48] `args` description --- src/utils/array/Each.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/array/Each.js b/src/utils/array/Each.js index 857251cf2..cc980135b 100644 --- a/src/utils/array/Each.js +++ b/src/utils/array/Each.js @@ -13,7 +13,7 @@ * @param {array} array - The array to search. * @param {function} callback - A callback to be invoked for each item in the array. * @param {object} context - The context in which the callback is invoked. - * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. + * @param {...*} [args] - Additional arguments that will be passed to the callback, after the current array item. * * @return {array} The input array. */ From bf995c700057db73aa7a49643f75af625459b001 Mon Sep 17 00:00:00 2001 From: Michael Hadley Date: Tue, 26 Jun 2018 20:30:01 -0500 Subject: [PATCH 31/48] Line#getPointB documentation typo fix: "start" is used where "end" was intended --- src/geom/line/Line.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/geom/line/Line.js b/src/geom/line/Line.js index 2b1dd9940..fd0038254 100644 --- a/src/geom/line/Line.js +++ b/src/geom/line/Line.js @@ -182,7 +182,7 @@ var Line = new Class({ }, /** - * Returns a Vector2 object that corresponds to the start of this Line. + * Returns a Vector2 object that corresponds to the end of this Line. * * @method Phaser.Geom.Line#getPointB * @since 3.0.0 @@ -191,7 +191,7 @@ var Line = new Class({ * * @param {Phaser.Math.Vector2} [vec2] - A Vector2 object to set the results in. If `undefined` a new Vector2 will be created. * - * @return {Phaser.Math.Vector2} A Vector2 object that corresponds to the start of this Line. + * @return {Phaser.Math.Vector2} A Vector2 object that corresponds to the end of this Line. */ getPointB: function (vec2) { From 32ff6df5b368f287cf629e7dae7bebcf84d12522 Mon Sep 17 00:00:00 2001 From: Andre van Tonder Date: Wed, 27 Jun 2018 10:33:35 +0800 Subject: [PATCH 32/48] fixed JsDoc for Phaser.Tilemaps.Tilemap#createBlankDynamicLayer x, y, width, height, tileWidth, tileHeight are all optional params I also add x, y params to jsdoc as they were missing --- src/tilemaps/Tilemap.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/tilemaps/Tilemap.js b/src/tilemaps/Tilemap.js index 9fe6fbc6c..a5e61bbed 100644 --- a/src/tilemaps/Tilemap.js +++ b/src/tilemaps/Tilemap.js @@ -372,13 +372,15 @@ var Tilemap = new Class({ * * @param {string} name - The name of this layer. Must be unique within the map. * @param {Phaser.Tilemaps.Tileset} tileset - The tileset the new layer will use. - * @param {integer} width - The width of the layer in tiles. If not specified, it will default + * @param {number} [x=0] - The world x position where the top left of this layer will be placed. + * @param {number} [y=0] - The world y position where the top left of this layer will be placed. + * @param {integer} [width] - The width of the layer in tiles. If not specified, it will default * to the map's width. - * @param {integer} height - The height of the layer in tiles. If not specified, it will default + * @param {integer} [height] - The height of the layer in tiles. If not specified, it will default * to the map's height. - * @param {integer} tileWidth - The width of the tiles the layer uses for calculations. If not + * @param {integer} [tileWidth] - The width of the tiles the layer uses for calculations. If not * specified, it will default to the map's tileWidth. - * @param {integer} tileHeight - The height of the tiles the layer uses for calculations. If not + * @param {integer} [tileHeight] - The height of the tiles the layer uses for calculations. If not * specified, it will default to the map's tileHeight. * @return {?Phaser.Tilemaps.DynamicTilemapLayer} Returns the new layer was created, or null if it failed. */ From d02d6532fd46989c97b9ea04ffe0c3a79e2db815 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Wed, 27 Jun 2018 11:20:21 +0100 Subject: [PATCH 33/48] TileSprite was using the Size compontent instead of ComputedSize, meaning its `getBounds` and `displayWidth` and `displayHeight` results were incorrect. Fix #3789 --- CHANGELOG.md | 4 +++- src/gameobjects/tilesprite/TileSprite.js | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f8a098d32..7fa629f17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,12 +57,14 @@ * `SceneManager.run` would ignore scenes that are currently in the queue of scenes pending to be added. This has now been fixed so that the scene is queued to be started once it's ready (thanks @rook2pawn) * `GameObject.disableInteractive` was toggling input. Every second call would turn the input back on (thanks @TadejZupancic) * The position of the TilemapLayer wasn't taken into account when culling tiles for the Camera. It's now calculated as part of the cull flow (thanks @Upperfoot) +* Fix extra argument passing in Array.Each (thanks @samme) +* TileSprite was using the Size compontent instead of ComputedSize, meaning its `getBounds` and `displayWidth` and `displayHeight` results were incorrect. Fix #3789 (thanks @jjalonso) ### Examples, Documentation and TypeScript My thanks to the following for helping with the Phaser 3 Examples, Docs and TypeScript definitions, either by reporting errors, fixing them or helping author the docs: -@DannyT @squilibob @dvdbrink @t1gu1 @cyantree @DrevanTonder +@DannyT @squilibob @dvdbrink @t1gu1 @cyantree @DrevanTonder @mikewesthad Also, a special mention to @andygroff for his excellent work enhancing the search box on the examples site. diff --git a/src/gameobjects/tilesprite/TileSprite.js b/src/gameobjects/tilesprite/TileSprite.js index 7a18f27a6..0a7111177 100644 --- a/src/gameobjects/tilesprite/TileSprite.js +++ b/src/gameobjects/tilesprite/TileSprite.js @@ -29,6 +29,7 @@ var TileSpriteRender = require('./TileSpriteRender'); * * @extends Phaser.GameObjects.Components.Alpha * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.ComputedSize * @extends Phaser.GameObjects.Components.Depth * @extends Phaser.GameObjects.Components.Flip * @extends Phaser.GameObjects.Components.GetBounds @@ -37,7 +38,6 @@ var TileSpriteRender = require('./TileSpriteRender'); * @extends Phaser.GameObjects.Components.Pipeline * @extends Phaser.GameObjects.Components.ScaleMode * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Size * @extends Phaser.GameObjects.Components.Texture * @extends Phaser.GameObjects.Components.Tint * @extends Phaser.GameObjects.Components.Transform @@ -58,6 +58,7 @@ var TileSprite = new Class({ Mixins: [ Components.Alpha, Components.BlendMode, + Components.ComputedSize, Components.Depth, Components.Flip, Components.GetBounds, @@ -66,7 +67,6 @@ var TileSprite = new Class({ Components.Pipeline, Components.ScaleMode, Components.ScrollFactor, - Components.Size, Components.Texture, Components.Tint, Components.Transform, From da2b91b460dfdc8b91649859fbf60b2ba1fa0efd Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Wed, 27 Jun 2018 11:31:51 +0100 Subject: [PATCH 34/48] ArrayUtils.AddAt didn't calculate the array offset correctly if you passed an array in to be merged with an existing array. This also caused Container.addAt to fail if an array was passed to it. Fix #3788 --- CHANGELOG.md | 3 ++- src/utils/array/AddAt.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7fa629f17..d7446a7b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -58,7 +58,8 @@ * `GameObject.disableInteractive` was toggling input. Every second call would turn the input back on (thanks @TadejZupancic) * The position of the TilemapLayer wasn't taken into account when culling tiles for the Camera. It's now calculated as part of the cull flow (thanks @Upperfoot) * Fix extra argument passing in Array.Each (thanks @samme) -* TileSprite was using the Size compontent instead of ComputedSize, meaning its `getBounds` and `displayWidth` and `displayHeight` results were incorrect. Fix #3789 (thanks @jjalonso) +* TileSprite was using the Size compontent instead of ComputedSize, meaning its `getBounds` and `displayWidth` and `displayHeight` results were incorrect. Fix #3789 (thanks @jjalonso) +* ArrayUtils.AddAt didn't calculate the array offset correctly if you passed an array in to be merged with an existing array. This also caused Container.addAt to fail if an array was passed to it. Fix #3788 (thanks @jjalonso) ### Examples, Documentation and TypeScript diff --git a/src/utils/array/AddAt.js b/src/utils/array/AddAt.js index 320726645..99ebc4517 100644 --- a/src/utils/array/AddAt.js +++ b/src/utils/array/AddAt.js @@ -98,7 +98,7 @@ var AddAt = function (array, item, index, limit, callback, context) itemLength = remaining; } - for (var i = itemLength; i > 0; i--) + for (var i = itemLength - 1; i >= 0; i--) { var entry = item[i]; From f2b7fd0a32f81bc1cdb54d59a4e7b2191f5fd662 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Wed, 27 Jun 2018 12:13:37 +0100 Subject: [PATCH 35/48] Removed the cameraX properties because they fall out of sync on camera remove --- CHANGELOG.md | 4 +- src/cameras/2d/CameraManager.js | 274 +++++++------------------------- 2 files changed, 59 insertions(+), 219 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d7446a7b6..1ec91161b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,6 @@ * `Camera.deadzone` (and its related method `Camera.setDeadzone`) allows you to specify the deadzone for a camera. The deadzone is a rectangular region used when a camera is following a target. If the target is within the deadzone then the camera will not scroll. As soon as the target leaves the deadzone, the camera will begin tracking it (applying lerp if needed.) It allows you to set a region of the camera in which a player can move freely before tracking begins. The deadzone is re-centered on the camera mid point every frame, meaning you can also use the rectangle for other in-game checks as needed. * `Camera.pan` is a new Camera Effect that allows you to control automatic camera pans between points in your game world. You can specify a duration and ease type for the pan, and it'll emit events just like all other camera effects, so you can hook into the start, update and completion of the pan. See the examples and docs for more details. * `Camera.zoom` is a new Camera Effect that allows you to control automatic camera zooming. You can specify a duration and ease type for the zoom, as well as the zoom factor of course, and it'll emit events just like all other camera effects, so you can hook into the start, update and completion of the zoom. Used in combination with the new Pan effect you can zoom and pan around with ease. See the examples and docs for more details. -* The Camera Manager has 10 new read-only properties: `camera1`, `camera2` and so on, up to `camera10` so you can now quickly access the first 10 cameras created in the Camera Manager without needing to hold your own references too. * `Camera.midPoint` is a new Vec2 property that is updated every frame. Use it to obtain exactly where in the world the center of the camera is currently looking. * `Camera.displayWidth` is a new property that returns the display width of the camera, factoring in the current zoom level. * `Camera.displayHeight` is a new property that returns the display height of the camera, factoring in the current zoom level. @@ -17,10 +16,11 @@ * The Camera bounds didn't factor in the camera zoom properly, meaning you would often not be able to reach the corners of a camera bound world at a zoom level other than 1. The bounds are now calculated each frame to ensure they match the zoom level and it will no longer allow you to scroll off the edge of the bounds. Fix #3547 (thanks @nkholski) * `Camera.centerToBounds` didn't take the bounds offset into account, so bounds at non-zero positions wouldn't center properly. All bounds now center correctly. Fix #3706 (thanks @cyantree) * `Camera.setBounds` has a new optional argument `centerOn`. If specified it will automatically center the camera on the new bounds given. +* The Camera will no longer stutter when following Game Objects at high zoom levels. * `Camera._id` has been renamed to `Camera.id`, a read-only bitmask used for camera exclusion from Game Objects. * The Camera Manager `cameraPool` has been removed entirely. It was mostly pointless in practise as Cameras are not regenerated frequently enough to need pooling. It also didn't maintain the bitmask list correctly before. * `CameraManager.resetAll` now destroys all current Cameras, resets the camera ID marker to 1 and adds a single new Camera. -* `CameraManager.currentCameraId` has been renamed to `nextID` and marked as read-only. +* `CameraManager.currentCameraId` has been removed. IDs are assigned more intelligently now, via the `getNextID` internal method. * `CameraManager.addExisting` no longer needs to be passed a Camera that already exists in the pool (as the pool has been removed), meaning you can now create your own Cameras and pass them to `addExisting` and have them treated as normal cameras and not be ignored by the manager. They are also assigned a proper ID when added. * `CameraManager.addExisting` has a new boolean argument `makeMain` which will make the new camera the main one. diff --git a/src/cameras/2d/CameraManager.js b/src/cameras/2d/CameraManager.js index 5a256bc5d..3be1b82b5 100644 --- a/src/cameras/2d/CameraManager.js +++ b/src/cameras/2d/CameraManager.js @@ -38,9 +38,6 @@ var RectangleContains = require('../../geom/rectangle/Contains'); * By default you can access the Camera Manager from within a Scene using `this.cameras`, although this can be changed * in your game config. * - * The Camera Manager can manage up to 31 unique Cameras. You can use the properties `camera1` through to `camera10` - * for quick and easy access to the first 10 cameras you define. - * * Create new Cameras using the `add` method. Or extend the Camera class with your own addition code and then add * the new Camera in using the `addExisting` method. * @@ -58,9 +55,12 @@ var RectangleContains = require('../../geom/rectangle/Contains'); * viewport, and changing the viewport has no impact on the scrolling. * * By default a Camera will render all Game Objects it can see. You can change this using the `ignore` method, - * allowing you to filter Game Objects out on a per-Camera basis. + * allowing you to filter Game Objects out on a per-Camera basis. The Camera Manager can manage up to 31 unique + * 'Game Object ignore capable' Cameras. Any Cameras beyond 31 that you create will all be given a Camera ID of + * zero, meaning that they cannot be used for Game Object exclusion. This means if you need your Camera to ignore + * Game Objects, make sure it's one of the first 31 created. * - * A Camera also has built-in special effects including Fade, Flash and Camera Shake. + * A Camera also has built-in special effects including Fade, Flash, Camera Shake, Pan and Zoom. * * @class CameraManager * @memberOf Phaser.Cameras.Scene2D @@ -93,18 +93,6 @@ var CameraManager = new Class({ */ this.systems = scene.sys; - /** - * The ID that will be assigned to the next Camera that is created. - * This is a bitmask value, meaning only up to 31 cameras can be created in total. - * - * @name Phaser.Cameras.Scene2D.CameraManager#nextID - * @type {integer} - * @default 1 - * @readOnly - * @since 3.0.0 - */ - this.nextID = 1; - /** * An Array of the Camera objects being managed by this Camera Manager. * The Cameras are updated and rendered in the same order in which they appear in this array. @@ -237,6 +225,8 @@ var CameraManager = new Class({ camera.setName(name); camera.setScene(this.scene); + camera.id = this.getNextID(); + this.cameras.push(camera); if (makeMain) @@ -244,13 +234,57 @@ var CameraManager = new Class({ this.main = camera; } - camera.id = this.nextID; - - this.nextID = this.nextID << 1; - return camera; }, + /** + * Gets the next available Camera ID number. + * + * The Camera Manager supports up to 31 unique cameras, after which the ID returned will always be zero. + * You can create additional cameras beyond 31, but they cannot be used for Game Object exclusion. + * + * @method Phaser.Cameras.Scene2D.CameraManager#getNextID + * @private + * @since 3.11.0 + * + * @return {number} The next available Camera ID, or 0 if they're all already in use. + */ + getNextID: function () + { + var cameras = this.cameras; + + var testID = 1; + + // Find the first free camera ID we can use + + for (var t = 0; t < 32; t++) + { + var found = false; + + for (var i = 0; i < cameras.length; i++) + { + var camera = cameras[i]; + + if (camera && camera.id === testID) + { + found = true; + continue; + } + } + + if (found) + { + testID = testID << 1; + } + else + { + return testID; + } + } + + return 0; + }, + /** * Adds an existing Camera into the Camera Manager. * @@ -277,12 +311,10 @@ var CameraManager = new Class({ if (index === -1) { + camera.id = this.getNextID(); + this.cameras.push(camera); - camera.id = this.nextID; - - this.nextID = this.nextID << 1; - if (makeMain) { this.main = camera; @@ -509,8 +541,6 @@ var CameraManager = new Class({ this.cameras = []; - this.nextID = 1; - this.main = this.add(); return this.main; @@ -592,196 +622,6 @@ var CameraManager = new Class({ this.scene = null; this.systems = null; - }, - - /** - * A reference to Camera 1 in the Camera Manager. - * - * Create additional cameras using the `add` method. - * - * @name Phaser.Cameras.Scene2D.CameraManager#camera1 - * @type {Phaser.Cameras.Scene2D.Camera} - * @readOnly - * @since 3.11.0 - */ - camera1: { - - get: function () - { - return this.cameras[0]; - } - - }, - - /** - * A reference to Camera 2 in the Camera Manager. - * - * This will be `undefined` by default unless you have created new cameras via `add` or `addExisting`. - * - * @name Phaser.Cameras.Scene2D.CameraManager#camera2 - * @type {Phaser.Cameras.Scene2D.Camera} - * @readOnly - * @since 3.11.0 - */ - camera2: { - - get: function () - { - return this.cameras[1]; - } - - }, - - /** - * A reference to Camera 3 in the Camera Manager. - * - * This will be `undefined` by default unless you have created new cameras via `add` or `addExisting`. - * - * @name Phaser.Cameras.Scene2D.CameraManager#camera3 - * @type {Phaser.Cameras.Scene2D.Camera} - * @readOnly - * @since 3.11.0 - */ - camera3: { - - get: function () - { - return this.cameras[2]; - } - - }, - - /** - * A reference to Camera 4 in the Camera Manager. - * - * This will be `undefined` by default unless you have created new cameras via `add` or `addExisting`. - * - * @name Phaser.Cameras.Scene2D.CameraManager#camera4 - * @type {Phaser.Cameras.Scene2D.Camera} - * @readOnly - * @since 3.11.0 - */ - camera4: { - - get: function () - { - return this.cameras[3]; - } - - }, - - /** - * A reference to Camera 5 in the Camera Manager. - * - * This will be `undefined` by default unless you have created new cameras via `add` or `addExisting`. - * - * @name Phaser.Cameras.Scene2D.CameraManager#camera5 - * @type {Phaser.Cameras.Scene2D.Camera} - * @readOnly - * @since 3.11.0 - */ - camera5: { - - get: function () - { - return this.cameras[4]; - } - - }, - - /** - * A reference to Camera 6 in the Camera Manager. - * - * This will be `undefined` by default unless you have created new cameras via `add` or `addExisting`. - * - * @name Phaser.Cameras.Scene2D.CameraManager#camera6 - * @type {Phaser.Cameras.Scene2D.Camera} - * @readOnly - * @since 3.11.0 - */ - camera6: { - - get: function () - { - return this.cameras[5]; - } - - }, - - /** - * A reference to Camera 7 in the Camera Manager. - * - * This will be `undefined` by default unless you have created new cameras via `add` or `addExisting`. - * - * @name Phaser.Cameras.Scene2D.CameraManager#camera7 - * @type {Phaser.Cameras.Scene2D.Camera} - * @readOnly - * @since 3.11.0 - */ - camera7: { - - get: function () - { - return this.cameras[6]; - } - - }, - - /** - * A reference to Camera 8 in the Camera Manager. - * - * This will be `undefined` by default unless you have created new cameras via `add` or `addExisting`. - * - * @name Phaser.Cameras.Scene2D.CameraManager#camera8 - * @type {Phaser.Cameras.Scene2D.Camera} - * @readOnly - * @since 3.11.0 - */ - camera8: { - - get: function () - { - return this.cameras[7]; - } - - }, - - /** - * A reference to Camera 9 in the Camera Manager. - * - * This will be `undefined` by default unless you have created new cameras via `add` or `addExisting`. - * - * @name Phaser.Cameras.Scene2D.CameraManager#camera9 - * @type {Phaser.Cameras.Scene2D.Camera} - * @readOnly - * @since 3.11.0 - */ - camera9: { - - get: function () - { - return this.cameras[8]; - } - - }, - - /** - * A reference to Camera 10 in the Camera Manager. - * - * This will be `undefined` by default unless you have created new cameras via `add` or `addExisting`. - * - * @name Phaser.Cameras.Scene2D.CameraManager#camera10 - * @type {Phaser.Cameras.Scene2D.Camera} - * @readOnly - * @since 3.11.0 - */ - camera10: { - - get: function () - { - return this.cameras[9]; - } - } }); From 88eb4f4ce9c3c681010dfe0a2c74156ac9914b89 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Wed, 27 Jun 2018 12:45:03 +0100 Subject: [PATCH 36/48] The `Pointer.camera` property would only be set if there was a viable Game Object in the camera view. Now it is set regardless, to always be the Camera the Pointer interacted with. --- src/input/InputPlugin.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/input/InputPlugin.js b/src/input/InputPlugin.js index 922874cf6..497cc981f 100644 --- a/src/input/InputPlugin.js +++ b/src/input/InputPlugin.js @@ -683,7 +683,7 @@ var InputPlugin = new Class({ { var camera = cameras[c]; - // Get a list of all objects that can be seen by the camera below the pointer in the scene and store in 'output' array. + // Get a list of all objects that can be seen by the camera below the pointer in the scene and store in 'over' array. // All objects in this array are input enabled, as checked by the hitTest method, so we don't need to check later on as well. var over = this.manager.hitTest(pointer, this._list, camera); @@ -706,6 +706,11 @@ var InputPlugin = new Class({ } } + // If we got this far then there were no Game Objects below the pointer, but it was still over + // a camera, so set that the top-most one into the pointer + + pointer.camera = cameras[0]; + return []; }, From 183f5c426080de0f75d1ae1a04351bda2fa22192 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Wed, 27 Jun 2018 12:45:54 +0100 Subject: [PATCH 37/48] `CameraManager.getTotal` is a new method that will return the total number of Cameras being managed, with an optional `isVisible` argument, that only counts visible cameras if set. --- CHANGELOG.md | 2 + src/cameras/2d/CameraManager.js | 83 +++++++++++++++++++++++---------- 2 files changed, 60 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ec91161b..6bcfada8a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ * `CameraManager.currentCameraId` has been removed. IDs are assigned more intelligently now, via the `getNextID` internal method. * `CameraManager.addExisting` no longer needs to be passed a Camera that already exists in the pool (as the pool has been removed), meaning you can now create your own Cameras and pass them to `addExisting` and have them treated as normal cameras and not be ignored by the manager. They are also assigned a proper ID when added. * `CameraManager.addExisting` has a new boolean argument `makeMain` which will make the new camera the main one. +* `CameraManager.getTotal` is a new method that will return the total number of Cameras being managed, with an optional `isVisible` argument, that only counts visible cameras if set. ### New Features @@ -60,6 +61,7 @@ * Fix extra argument passing in Array.Each (thanks @samme) * TileSprite was using the Size compontent instead of ComputedSize, meaning its `getBounds` and `displayWidth` and `displayHeight` results were incorrect. Fix #3789 (thanks @jjalonso) * ArrayUtils.AddAt didn't calculate the array offset correctly if you passed an array in to be merged with an existing array. This also caused Container.addAt to fail if an array was passed to it. Fix #3788 (thanks @jjalonso) +* The `Pointer.camera` property would only be set if there was a viable Game Object in the camera view. Now it is set regardless, to always be the Camera the Pointer interacted with. ### Examples, Documentation and TypeScript diff --git a/src/cameras/2d/CameraManager.js b/src/cameras/2d/CameraManager.js index 3be1b82b5..3bd42b560 100644 --- a/src/cameras/2d/CameraManager.js +++ b/src/cameras/2d/CameraManager.js @@ -237,6 +237,47 @@ var CameraManager = new Class({ return camera; }, + /** + * Adds an existing Camera into the Camera Manager. + * + * The Camera should either be a `Phaser.Cameras.Scene2D.Camera` instance, or a class that extends from it. + * + * The Camera will be assigned an ID, which is used for Game Object exclusion and then added to the + * manager. As long as it doesn't already exist in the manager it will be added then returned. + * + * If this method returns `null` then the Camera already exists in this Camera Manager. + * + * @method Phaser.Cameras.Scene2D.CameraManager#addExisting + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to be added to the Camera Manager. + * @param {boolean} [makeMain=false] - Set this Camera as being the 'main' camera. This just makes the property `main` a reference to it. + * + * @return {?Phaser.Cameras.Scene2D.Camera} The Camera that was added to the Camera Manager, or `null` if it couldn't be added. + */ + addExisting: function (camera, makeMain) + { + if (makeMain === undefined) { makeMain = false; } + + var index = this.cameras.indexOf(camera); + + if (index === -1) + { + camera.id = this.getNextID(); + + this.cameras.push(camera); + + if (makeMain) + { + this.main = camera; + } + + return camera; + } + + return null; + }, + /** * Gets the next available Camera ID number. * @@ -286,44 +327,36 @@ var CameraManager = new Class({ }, /** - * Adds an existing Camera into the Camera Manager. + * Gets the total number of Cameras in this Camera Manager. * - * The Camera should either be a `Phaser.Cameras.Scene2D.Camera` instance, or a class that extends from it. + * If the optional `isVisible` argument is set it will only count Cameras that are currently visible. + * + * @method Phaser.Cameras.Scene2D.CameraManager#getTotal + * @since 3.11.0 * - * The Camera will be assigned an ID, which is used for Game Object exclusion and then added to the - * manager. As long as it doesn't already exist in the manager it will be added then returned. - * - * If this method returns `null` then the Camera already exists in this Camera Manager. + * @param {boolean} [isVisible=false] - Set the `true` to only include visible Cameras in the total. * - * @method Phaser.Cameras.Scene2D.CameraManager#addExisting - * @since 3.0.0 - * - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to be added to the Camera Manager. - * @param {boolean} [makeMain=false] - Set this Camera as being the 'main' camera. This just makes the property `main` a reference to it. - * - * @return {?Phaser.Cameras.Scene2D.Camera} The Camera that was added to the Camera Manager, or `null` if it couldn't be added. + * @return {integer} The total number of Cameras in this Camera Manager. */ - addExisting: function (camera, makeMain) + getTotal: function (isVisible) { - if (makeMain === undefined) { makeMain = false; } + if (isVisible === undefined) { isVisible = false; } - var index = this.cameras.indexOf(camera); + var total = 0; - if (index === -1) + var cameras = this.cameras; + + for (var i = 0; i < cameras.length; i++) { - camera.id = this.getNextID(); + var camera = cameras[i]; - this.cameras.push(camera); - - if (makeMain) + if (!isVisible || (isVisible && camera.visible)) { - this.main = camera; + total++; } - - return camera; } - return null; + return total; }, /** From 1bfe58ab5571d88cc5463d04ae79d262a4972f93 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Wed, 27 Jun 2018 13:03:40 +0100 Subject: [PATCH 38/48] remove can take an array of cameras and also no longer needs total to be > 0 --- CHANGELOG.md | 2 ++ src/cameras/2d/CameraManager.js | 27 +++++++++++++++++++-------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bcfada8a..984874f4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,8 @@ * `CameraManager.addExisting` no longer needs to be passed a Camera that already exists in the pool (as the pool has been removed), meaning you can now create your own Cameras and pass them to `addExisting` and have them treated as normal cameras and not be ignored by the manager. They are also assigned a proper ID when added. * `CameraManager.addExisting` has a new boolean argument `makeMain` which will make the new camera the main one. * `CameraManager.getTotal` is a new method that will return the total number of Cameras being managed, with an optional `isVisible` argument, that only counts visible cameras if set. +* `CameraManager.remove` can now take an array of cameras to be removed from the manager, as well as a single camera. +* `CameraManager.remove` would previously not allow you to remove a camera if it meant there would be no cameras left in the Camera Manager. This restriction has been removed. A Camera Manager can now run even with zero cameras. Your game obviously won't display anything, but it's still now possible. ### New Features diff --git a/src/cameras/2d/CameraManager.js b/src/cameras/2d/CameraManager.js index 3bd42b560..3656fbfe0 100644 --- a/src/cameras/2d/CameraManager.js +++ b/src/cameras/2d/CameraManager.js @@ -492,7 +492,7 @@ var CameraManager = new Class({ }, /** - * Removes the given Camera from this Camera Manager. + * Removes the given Camera, or an array of Cameras, from this Camera Manager. * * If found in the Camera Manager it will be immediately removed from the local cameras array. * If also currently the 'main' camera, 'main' will be reset to be camera 0. @@ -503,21 +503,32 @@ var CameraManager = new Class({ * @method Phaser.Cameras.Scene2D.CameraManager#remove * @since 3.0.0 * - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to be removed from this Camera Manager. + * @param {(Phaser.Cameras.Scene2D.Camera|Phaser.Cameras.Scene2D.Camera[])} camera - The Camera, or an array of Cameras, to be removed from this Camera Manager. */ remove: function (camera) { - var cameraIndex = this.cameras.indexOf(camera); - - if (cameraIndex >= 0 && this.cameras.length > 1) + if (!Array.isArray(camera)) { - this.cameras.splice(cameraIndex, 1); + camera = [ camera ]; + } - if (this.main === camera) + var cameras = this.cameras; + + for (var i = 0; i < camera.length; i++) + { + var index = cameras.indexOf(camera); + + if (index !== -1) { - this.main = this.cameras[0]; + cameras.splice(index, 1); + } } + + if (!this.main) + { + this.main = this.cameras[0]; + } }, /** From 2888fe94bdd8ad0a97b2bf4b3142b291a833fe76 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Wed, 27 Jun 2018 13:05:06 +0100 Subject: [PATCH 39/48] Tweak --- src/cameras/2d/CameraManager.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cameras/2d/CameraManager.js b/src/cameras/2d/CameraManager.js index 3656fbfe0..9ac4e84d1 100644 --- a/src/cameras/2d/CameraManager.js +++ b/src/cameras/2d/CameraManager.js @@ -516,7 +516,7 @@ var CameraManager = new Class({ for (var i = 0; i < camera.length; i++) { - var index = cameras.indexOf(camera); + var index = cameras.indexOf(camera[i]); if (index !== -1) { @@ -527,7 +527,7 @@ var CameraManager = new Class({ if (!this.main) { - this.main = this.cameras[0]; + this.main = cameras[0]; } }, From ee8e264d5ec84441aadc93de4a3f40c5fd9acc0c Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Wed, 27 Jun 2018 13:16:01 +0100 Subject: [PATCH 40/48] Return removed total --- src/cameras/2d/CameraManager.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cameras/2d/CameraManager.js b/src/cameras/2d/CameraManager.js index 9ac4e84d1..59d02f72a 100644 --- a/src/cameras/2d/CameraManager.js +++ b/src/cameras/2d/CameraManager.js @@ -504,6 +504,8 @@ var CameraManager = new Class({ * @since 3.0.0 * * @param {(Phaser.Cameras.Scene2D.Camera|Phaser.Cameras.Scene2D.Camera[])} camera - The Camera, or an array of Cameras, to be removed from this Camera Manager. + * + * @return {integer} The total number of Cameras removed. */ remove: function (camera) { @@ -512,6 +514,7 @@ var CameraManager = new Class({ camera = [ camera ]; } + var total = 0; var cameras = this.cameras; for (var i = 0; i < camera.length; i++) @@ -521,7 +524,7 @@ var CameraManager = new Class({ if (index !== -1) { cameras.splice(index, 1); - + total++; } } @@ -529,6 +532,8 @@ var CameraManager = new Class({ { this.main = cameras[0]; } + + return total; }, /** From a6ab61dd99c243df3561e58c4e8e11866d9fdbc5 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Wed, 27 Jun 2018 13:16:11 +0100 Subject: [PATCH 41/48] Fixed id use --- src/cameras/2d/Camera.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cameras/2d/Camera.js b/src/cameras/2d/Camera.js index 5ec5471e2..c26abf484 100644 --- a/src/cameras/2d/Camera.js +++ b/src/cameras/2d/Camera.js @@ -1061,7 +1061,7 @@ var Camera = new Class({ */ ignore: function (gameObject) { - var id = this._id; + var id = this.id; if (Array.isArray(gameObject)) { From 7a23378015b4a6bfe05446629ced33a0810e7285 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Wed, 27 Jun 2018 15:15:00 +0100 Subject: [PATCH 42/48] Unified use of roundPixels, antialias and pixelArt modes --- CHANGELOG.md | 15 ++++++++++++ src/boot/Config.js | 2 +- src/boot/CreateRenderer.js | 4 ++-- src/cameras/2d/Camera.js | 5 ++-- src/cameras/2d/CameraManager.js | 23 +++++++++++++++++++ .../DynamicBitmapTextCanvasRenderer.js | 4 +--- .../static/BitmapTextCanvasRenderer.js | 6 ++--- .../ParticleManagerCanvasRenderer.js | 4 +--- .../text/static/TextCanvasRenderer.js | 2 +- .../tilesprite/TileSpriteCanvasRenderer.js | 2 +- src/renderer/canvas/CanvasRenderer.js | 5 ++-- src/renderer/canvas/utils/DrawImage.js | 13 ++--------- src/renderer/webgl/WebGLRenderer.js | 3 ++- .../webgl/pipelines/TextureTintPipeline.js | 16 ++++++------- src/textures/TextureSource.js | 2 +- 15 files changed, 66 insertions(+), 40 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 984874f4d..58caa8628 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,21 @@ * `CameraManager.getTotal` is a new method that will return the total number of Cameras being managed, with an optional `isVisible` argument, that only counts visible cameras if set. * `CameraManager.remove` can now take an array of cameras to be removed from the manager, as well as a single camera. * `CameraManager.remove` would previously not allow you to remove a camera if it meant there would be no cameras left in the Camera Manager. This restriction has been removed. A Camera Manager can now run even with zero cameras. Your game obviously won't display anything, but it's still now possible. +* `CameraManager.remove` will now return the total number of Cameras removed. + +### Round Pixels Changes + +Before explaining the changes it's worth covering what the three different game config properties do: + +`roundPixels` - this will cause the renderer to draw most Game Objects at whole integer positions. Their actual positions can be anything, but the renderer will floor the values to ensure they are integers immediately before drawing. It only works on texture based Game Objects. Graphics objects, for instance, ignore this property. + +`antialias` - when set to `true` WebGL textures are created using `gl.LINEAR`, which allows WebGL to try its best to interpolate the texture when rendered at non-texture frame sizes. This can happen if you scale a Game Object, or zoom a Camera. In both cases it will need to interpolate the pixel values to accommodate the new size. If this property is set to `false` then it will use `gl.NEAREST` instead. This uses a nearest neighbor method of interpolation, and is nearly always the better option if you need to keep the textures crisp, such as when using scaled pixel art. Disabling `antialias` invokes nearest-neighbor interpolation on the game canvas itself as well. If you need a mixture of aliased and anti-aliased textures in your game, then you can change them on a per-texture basis by using `Texture.setFilter`. + +There is a third game config property called `pixelArt`. If set to `true` it's the same thing as enabling `roundPixels` and disabling `antialias`. This is the optimum setting for pixel art games. + +* Both renderers will now check for `pixelArt` OR `antialias` before setting the canvas scale mode. Both values are checked during texture creation as well. +* If in your game config you have enabled either pixel art mode or roundPixels, then all Cameras will have their `roundPixels` values set to `true` by default. You can toggle this by changing the `CameraManager.roundPixels` property, or change it on a camera-by-camera basis, as needed. +* `Camera.roundPixels` is now used across all rendering code for both Canvas and WebGL. Previously, it would check the renderer config value, but now all renderer code uses the camera value to decide if it should floor the drawing position or not. ### New Features diff --git a/src/boot/Config.js b/src/boot/Config.js index b05667951..edd2c2ab4 100644 --- a/src/boot/Config.js +++ b/src/boot/Config.js @@ -341,7 +341,7 @@ var Config = new Class({ /** * @const {boolean} Phaser.Boot.Config#roundPixels - [description] */ - this.roundPixels = GetValue(renderConfig, 'roundPixels', false); + this.roundPixels = GetValue(renderConfig, 'roundPixels', this.pixelArt); /** * @const {boolean} Phaser.Boot.Config#transparent - [description] diff --git a/src/boot/CreateRenderer.js b/src/boot/CreateRenderer.js index 908fbe834..5cc14a5c9 100644 --- a/src/boot/CreateRenderer.js +++ b/src/boot/CreateRenderer.js @@ -48,7 +48,7 @@ var CreateRenderer = function (game) } // Pixel Art mode? - if (config.pixelArt) + if (config.pixelArt || !config.antialias) { CanvasPool.disableSmoothing(); } @@ -70,7 +70,7 @@ var CreateRenderer = function (game) } // Pixel Art mode? - if (config.pixelArt) + if (config.pixelArt || !config.antialias) { CanvasInterpolation.setCrisp(game.canvas); } diff --git a/src/cameras/2d/Camera.js b/src/cameras/2d/Camera.js index c26abf484..980be2549 100644 --- a/src/cameras/2d/Camera.js +++ b/src/cameras/2d/Camera.js @@ -1462,8 +1462,9 @@ var Camera = new Class({ }, /** - * Should the Camera round pixel values to whole integers when scrolling? - * In some types of game this is required to prevent sub-pixel aliasing. + * Should the Camera round pixel values to whole integers when rendering Game Objects? + * + * In some types of game, especially with pixel art, this is required to prevent sub-pixel aliasing. * * @method Phaser.Cameras.Scene2D.Camera#setRoundPixels * @since 3.0.0 diff --git a/src/cameras/2d/CameraManager.js b/src/cameras/2d/CameraManager.js index 59d02f72a..592798b56 100644 --- a/src/cameras/2d/CameraManager.js +++ b/src/cameras/2d/CameraManager.js @@ -93,6 +93,18 @@ var CameraManager = new Class({ */ this.systems = scene.sys; + /** + * All Cameras created by, or added to, this Camera Manager, will have their `roundPixels` + * property set to match this value. By default it is set to match the value set in the + * game configuration, but can be changed at any point. Equally, individual cameras can + * also be changed as needed. + * + * @name Phaser.Cameras.Scene2D.CameraManager#roundPixels + * @type {boolean} + * @since 3.11.0 + */ + this.roundPixels = scene.sys.game.config.roundPixels; + /** * An Array of the Camera objects being managed by this Camera Manager. * The Cameras are updated and rendered in the same order in which they appear in this array. @@ -197,6 +209,10 @@ var CameraManager = new Class({ * By default Cameras are transparent and will render anything that they can see based on their `scrollX` * and `scrollY` values. Game Objects can be set to be ignored by a Camera by using the `Camera.ignore` method. * + * Please note that it will have its `roundPixels` propery set to whatever is set on the game and renderer + * configuration. So if you've got a game config with `pixelArt: true` in it, then `roundPixels` will always + * be set to `true` on the new Camera. + * * See the Camera class documentation for more details. * * @method Phaser.Cameras.Scene2D.CameraManager#add @@ -224,6 +240,7 @@ var CameraManager = new Class({ camera.setName(name); camera.setScene(this.scene); + camera.setRoundPixels(this.roundPixels); camera.id = this.getNextID(); @@ -242,6 +259,10 @@ var CameraManager = new Class({ * * The Camera should either be a `Phaser.Cameras.Scene2D.Camera` instance, or a class that extends from it. * + * Please note that it will have its `roundPixels` propery set to whatever is set on the game and renderer + * configuration. So if you've got a game config with `pixelArt: true` in it, then `roundPixels` will always + * be set to `true` on the Camera added to this Camera Manager. + * * The Camera will be assigned an ID, which is used for Game Object exclusion and then added to the * manager. As long as it doesn't already exist in the manager it will be added then returned. * @@ -265,6 +286,8 @@ var CameraManager = new Class({ { camera.id = this.getNextID(); + camera.setRoundPixels(this.roundPixels); + this.cameras.push(camera); if (makeMain) diff --git a/src/gameobjects/bitmaptext/dynamic/DynamicBitmapTextCanvasRenderer.js b/src/gameobjects/bitmaptext/dynamic/DynamicBitmapTextCanvasRenderer.js index 23d302139..31874a262 100644 --- a/src/gameobjects/bitmaptext/dynamic/DynamicBitmapTextCanvasRenderer.js +++ b/src/gameobjects/bitmaptext/dynamic/DynamicBitmapTextCanvasRenderer.js @@ -127,8 +127,6 @@ var DynamicBitmapTextCanvasRenderer = function (renderer, src, interpolationPerc ctx.clip(); } - var roundPixels = renderer.config.roundPixels; - for (var index = 0; index < textLength; ++index) { // Reset the scale (in case the callback changed it) @@ -186,7 +184,7 @@ var DynamicBitmapTextCanvasRenderer = function (renderer, src, interpolationPerc x -= cameraScrollX; y -= cameraScrollY; - if (roundPixels) + if (camera.roundPixels) { x |= 0; y |= 0; diff --git a/src/gameobjects/bitmaptext/static/BitmapTextCanvasRenderer.js b/src/gameobjects/bitmaptext/static/BitmapTextCanvasRenderer.js index c5471a834..047054bc9 100644 --- a/src/gameobjects/bitmaptext/static/BitmapTextCanvasRenderer.js +++ b/src/gameobjects/bitmaptext/static/BitmapTextCanvasRenderer.js @@ -91,12 +91,10 @@ var BitmapTextCanvasRenderer = function (renderer, src, interpolationPercentage, renderer.currentScaleMode = src.scaleMode; } - var roundPixels = renderer.config.roundPixels; - var tx = (src.x - camera.scrollX * src.scrollFactorX) + src.frame.x; var ty = (src.y - camera.scrollY * src.scrollFactorY) + src.frame.y; - if (roundPixels) + if (camera.roundPixels) { tx |= 0; ty |= 0; @@ -167,7 +165,7 @@ var BitmapTextCanvasRenderer = function (renderer, src, interpolationPercentage, continue; } - if (roundPixels) + if (camera.roundPixels) { x |= 0; y |= 0; diff --git a/src/gameobjects/particles/ParticleManagerCanvasRenderer.js b/src/gameobjects/particles/ParticleManagerCanvasRenderer.js index d7e65134d..1a8df0b35 100644 --- a/src/gameobjects/particles/ParticleManagerCanvasRenderer.js +++ b/src/gameobjects/particles/ParticleManagerCanvasRenderer.js @@ -64,8 +64,6 @@ var ParticleManagerCanvasRenderer = function (renderer, emitterManager, interpol ctx.globalCompositeOperation = renderer.blendModes[emitter.blendMode]; } - var roundPixels = renderer.config.roundPixels; - for (var index = 0; index < length; ++index) { var particle = particles[index]; @@ -90,7 +88,7 @@ var ParticleManagerCanvasRenderer = function (renderer, emitterManager, interpol var tx = particle.x - cameraScrollX; var ty = particle.y - cameraScrollY; - if (roundPixels) + if (camera.roundPixels) { tx |= 0; ty |= 0; diff --git a/src/gameobjects/text/static/TextCanvasRenderer.js b/src/gameobjects/text/static/TextCanvasRenderer.js index a6834ba1e..1fb2b37a3 100644 --- a/src/gameobjects/text/static/TextCanvasRenderer.js +++ b/src/gameobjects/text/static/TextCanvasRenderer.js @@ -73,7 +73,7 @@ var TextCanvasRenderer = function (renderer, src, interpolationPercentage, camer var tx = src.x - camera.scrollX * src.scrollFactorX; var ty = src.y - camera.scrollY * src.scrollFactorY; - if (renderer.config.roundPixels) + if (camera.roundPixels) { tx |= 0; ty |= 0; diff --git a/src/gameobjects/tilesprite/TileSpriteCanvasRenderer.js b/src/gameobjects/tilesprite/TileSpriteCanvasRenderer.js index b25e88abb..dfbc7ad46 100644 --- a/src/gameobjects/tilesprite/TileSpriteCanvasRenderer.js +++ b/src/gameobjects/tilesprite/TileSpriteCanvasRenderer.js @@ -86,7 +86,7 @@ var TileSpriteCanvasRenderer = function (renderer, src, interpolationPercentage, dy += src.height; } - if (renderer.config.roundPixels) + if (camera.roundPixels) { dx |= 0; dy |= 0; diff --git a/src/renderer/canvas/CanvasRenderer.js b/src/renderer/canvas/CanvasRenderer.js index a967f9cb2..c95f79ce3 100644 --- a/src/renderer/canvas/CanvasRenderer.js +++ b/src/renderer/canvas/CanvasRenderer.js @@ -90,6 +90,7 @@ var CanvasRenderer = new Class({ backgroundColor: game.config.backgroundColor, resolution: game.config.resolution, autoResize: game.config.autoResize, + antialias: game.config.antialias, roundPixels: game.config.roundPixels }; @@ -100,7 +101,7 @@ var CanvasRenderer = new Class({ * @type {integer} * @since 3.0.0 */ - this.scaleMode = (game.config.pixelArt) ? ScaleModes.NEAREST : ScaleModes.LINEAR; + this.scaleMode = (game.config.pixelArt || !game.config.antialias) ? ScaleModes.NEAREST : ScaleModes.LINEAR; /** * [description] @@ -136,7 +137,7 @@ var CanvasRenderer = new Class({ * @type {function} * @since 3.0.0 */ - this.drawImage = DrawImage(this.config.roundPixels); + this.drawImage = DrawImage; /** * [description] diff --git a/src/renderer/canvas/utils/DrawImage.js b/src/renderer/canvas/utils/DrawImage.js index cd87407f9..f0d56c27e 100644 --- a/src/renderer/canvas/utils/DrawImage.js +++ b/src/renderer/canvas/utils/DrawImage.js @@ -4,8 +4,6 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var roundPixels = false; - /** * [description] * @@ -80,7 +78,7 @@ var DrawImage = function (src, camera, parentMatrix) var tx = src.x - camera.scrollX * src.scrollFactorX; var ty = src.y - camera.scrollY * src.scrollFactorY; - if (roundPixels) + if (camera.roundPixels) { tx |= 0; ty |= 0; @@ -111,11 +109,4 @@ var DrawImage = function (src, camera, parentMatrix) ctx.restore(); }; -// Special return so we can store the config value locally - -module.exports = function (configRoundPixels) -{ - roundPixels = configRoundPixels; - - return DrawImage; -}; +module.exports = DrawImage; diff --git a/src/renderer/webgl/WebGLRenderer.js b/src/renderer/webgl/WebGLRenderer.js index 5da8c6210..e65963b49 100644 --- a/src/renderer/webgl/WebGLRenderer.js +++ b/src/renderer/webgl/WebGLRenderer.js @@ -81,6 +81,7 @@ var WebGLRenderer = new Class({ this.config = { clearBeforeRender: gameConfig.clearBeforeRender, pixelArt: gameConfig.pixelArt, + antialias: gameConfig.antialias, backgroundColor: gameConfig.backgroundColor, contextCreation: contextCreationConfig, resolution: gameConfig.resolution, @@ -1124,7 +1125,7 @@ var WebGLRenderer = new Class({ { filter = gl.LINEAR; } - else if (scaleMode === CONST.ScaleModes.NEAREST || this.config.pixelArt) + else if (scaleMode === CONST.ScaleModes.NEAREST || this.config.pixelArt || !this.config.antialias) { filter = gl.NEAREST; } diff --git a/src/renderer/webgl/pipelines/TextureTintPipeline.js b/src/renderer/webgl/pipelines/TextureTintPipeline.js index 0b1d60f67..2c881b879 100644 --- a/src/renderer/webgl/pipelines/TextureTintPipeline.js +++ b/src/renderer/webgl/pipelines/TextureTintPipeline.js @@ -397,7 +397,7 @@ var TextureTintPipeline = new Class({ this.renderer.setPipeline(this); - var roundPixels = this.renderer.config.roundPixels; + var roundPixels = camera.roundPixels; var emitters = emitterManager.emitters.list; var emitterCount = emitters.length; var vertexViewF32 = this.vertexViewF32; @@ -620,7 +620,7 @@ var TextureTintPipeline = new Class({ this.renderer.setPipeline(this); - var roundPixels = this.renderer.config.roundPixels; + var roundPixels = camera.roundPixels; var getTint = Utils.getTintAppendFloatAlpha; var vertexViewF32 = this.vertexViewF32; var vertexViewU32 = this.vertexViewU32; @@ -801,7 +801,7 @@ var TextureTintPipeline = new Class({ this.flush(); } - var roundPixels = this.renderer.config.roundPixels; + var roundPixels = camera.roundPixels; var getTint = Utils.getTintAppendFloatAlpha; var vertexViewF32 = this.vertexViewF32; var vertexViewU32 = this.vertexViewU32; @@ -978,7 +978,7 @@ var TextureTintPipeline = new Class({ this.flush(); } - var roundPixels = this.renderer.config.roundPixels; + var roundPixels = camera.roundPixels; var getTint = Utils.getTintAppendFloatAlpha; var uvs = mesh.uv; var colors = mesh.colors; @@ -1105,7 +1105,7 @@ var TextureTintPipeline = new Class({ this.flush(); } - var roundPixels = this.renderer.config.roundPixels; + var roundPixels = camera.roundPixels; var text = bitmapText.text; var textLength = text.length; var getTint = Utils.getTintAppendFloatAlpha; @@ -1382,7 +1382,7 @@ var TextureTintPipeline = new Class({ this.flush(); } - var roundPixels = this.renderer.config.roundPixels; + var roundPixels = camera.roundPixels; var displayCallback = bitmapText.displayCallback; var text = bitmapText.text; var textLength = text.length; @@ -1906,7 +1906,7 @@ var TextureTintPipeline = new Class({ flipY = flipY ^ (texture.isRenderTexture ? 1 : 0); - var roundPixels = this.renderer.config.roundPixels; + var roundPixels = camera.roundPixels; var vertexViewF32 = this.vertexViewF32; var vertexViewU32 = this.vertexViewU32; var cameraMatrix = camera.matrix.matrix; @@ -2080,7 +2080,7 @@ var TextureTintPipeline = new Class({ this.flush(); } - var roundPixels = this.renderer.config.roundPixels; + var roundPixels = camera.roundPixels; var vertexViewF32 = this.vertexViewF32; var vertexViewU32 = this.vertexViewU32; var width = frameWidth; diff --git a/src/textures/TextureSource.js b/src/textures/TextureSource.js index 2c8fd1561..544d34322 100644 --- a/src/textures/TextureSource.js +++ b/src/textures/TextureSource.js @@ -164,7 +164,7 @@ var TextureSource = new Class({ } } - if (game.config.pixelArt) + if (game.config.pixelArt || !game.config.antialias) { this.setFilter(1); } From 8c312090da7543e2253863a3fe43eb2637800492 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Wed, 27 Jun 2018 15:27:16 +0100 Subject: [PATCH 43/48] Solidified use of pixelArt mode --- src/boot/Config.js | 24 ++++++++++++------- src/boot/CreateRenderer.js | 4 ++-- src/cameras/2d/CameraManager.js | 10 ++++---- src/renderer/canvas/CanvasRenderer.js | 3 +-- src/renderer/index.js | 2 +- src/renderer/webgl/WebGLRenderer.js | 3 +-- .../webgl/pipelines/TextureTintPipeline.js | 2 +- src/textures/TextureSource.js | 2 +- 8 files changed, 26 insertions(+), 24 deletions(-) diff --git a/src/boot/Config.js b/src/boot/Config.js index edd2c2ab4..7211a1756 100644 --- a/src/boot/Config.js +++ b/src/boot/Config.js @@ -323,25 +323,31 @@ var Config = new Class({ var renderConfig = GetValue(config, 'render', config); + /** + * @const {boolean} Phaser.Boot.Config#autoResize - [description] + */ + this.autoResize = GetValue(renderConfig, 'autoResize', false); + /** * @const {boolean} Phaser.Boot.Config#antialias - [description] */ this.antialias = GetValue(renderConfig, 'antialias', true); + /** + * @const {boolean} Phaser.Boot.Config#roundPixels - [description] + */ + this.roundPixels = GetValue(renderConfig, 'roundPixels', false); + /** * @const {boolean} Phaser.Boot.Config#pixelArt - [description] */ this.pixelArt = GetValue(renderConfig, 'pixelArt', false); - /** - * @const {boolean} Phaser.Boot.Config#autoResize - [description] - */ - this.autoResize = GetValue(renderConfig, 'autoResize', false); - - /** - * @const {boolean} Phaser.Boot.Config#roundPixels - [description] - */ - this.roundPixels = GetValue(renderConfig, 'roundPixels', this.pixelArt); + if (this.pixelArt) + { + this.antialias = false; + this.roundPixels = true; + } /** * @const {boolean} Phaser.Boot.Config#transparent - [description] diff --git a/src/boot/CreateRenderer.js b/src/boot/CreateRenderer.js index 5cc14a5c9..b45ab8de3 100644 --- a/src/boot/CreateRenderer.js +++ b/src/boot/CreateRenderer.js @@ -48,7 +48,7 @@ var CreateRenderer = function (game) } // Pixel Art mode? - if (config.pixelArt || !config.antialias) + if (!config.antialias) { CanvasPool.disableSmoothing(); } @@ -70,7 +70,7 @@ var CreateRenderer = function (game) } // Pixel Art mode? - if (config.pixelArt || !config.antialias) + if (!config.antialias) { CanvasInterpolation.setCrisp(game.canvas); } diff --git a/src/cameras/2d/CameraManager.js b/src/cameras/2d/CameraManager.js index 592798b56..45d19824b 100644 --- a/src/cameras/2d/CameraManager.js +++ b/src/cameras/2d/CameraManager.js @@ -209,9 +209,8 @@ var CameraManager = new Class({ * By default Cameras are transparent and will render anything that they can see based on their `scrollX` * and `scrollY` values. Game Objects can be set to be ignored by a Camera by using the `Camera.ignore` method. * - * Please note that it will have its `roundPixels` propery set to whatever is set on the game and renderer - * configuration. So if you've got a game config with `pixelArt: true` in it, then `roundPixels` will always - * be set to `true` on the new Camera. + * The Camera will have its `roundPixels` propery set to whatever `CameraManager.roundPixels` is. You can change + * it after creation if required. * * See the Camera class documentation for more details. * @@ -259,9 +258,8 @@ var CameraManager = new Class({ * * The Camera should either be a `Phaser.Cameras.Scene2D.Camera` instance, or a class that extends from it. * - * Please note that it will have its `roundPixels` propery set to whatever is set on the game and renderer - * configuration. So if you've got a game config with `pixelArt: true` in it, then `roundPixels` will always - * be set to `true` on the Camera added to this Camera Manager. + * The Camera will have its `roundPixels` propery set to whatever `CameraManager.roundPixels` is. You can change + * it after addition if required. * * The Camera will be assigned an ID, which is used for Game Object exclusion and then added to the * manager. As long as it doesn't already exist in the manager it will be added then returned. diff --git a/src/renderer/canvas/CanvasRenderer.js b/src/renderer/canvas/CanvasRenderer.js index c95f79ce3..e23d27eb2 100644 --- a/src/renderer/canvas/CanvasRenderer.js +++ b/src/renderer/canvas/CanvasRenderer.js @@ -86,7 +86,6 @@ var CanvasRenderer = new Class({ */ this.config = { clearBeforeRender: game.config.clearBeforeRender, - pixelArt: game.config.pixelArt, backgroundColor: game.config.backgroundColor, resolution: game.config.resolution, autoResize: game.config.autoResize, @@ -101,7 +100,7 @@ var CanvasRenderer = new Class({ * @type {integer} * @since 3.0.0 */ - this.scaleMode = (game.config.pixelArt || !game.config.antialias) ? ScaleModes.NEAREST : ScaleModes.LINEAR; + this.scaleMode = (game.config.antialias) ? ScaleModes.LINEAR : ScaleModes.NEAREST; /** * [description] diff --git a/src/renderer/index.js b/src/renderer/index.js index 15b7a53c1..a7b531266 100644 --- a/src/renderer/index.js +++ b/src/renderer/index.js @@ -8,7 +8,7 @@ * @typedef {object} RendererConfig * * @property {boolean} clearBeforeRender - [description] - * @property {boolean} pixelArt - [description] + * @property {boolean} antialias - [description] * @property {Phaser.Display.Color} backgroundColor - [description] * @property {number} resolution - [description] * @property {boolean} autoResize - [description] diff --git a/src/renderer/webgl/WebGLRenderer.js b/src/renderer/webgl/WebGLRenderer.js index e65963b49..6aef8b1f0 100644 --- a/src/renderer/webgl/WebGLRenderer.js +++ b/src/renderer/webgl/WebGLRenderer.js @@ -80,7 +80,6 @@ var WebGLRenderer = new Class({ */ this.config = { clearBeforeRender: gameConfig.clearBeforeRender, - pixelArt: gameConfig.pixelArt, antialias: gameConfig.antialias, backgroundColor: gameConfig.backgroundColor, contextCreation: contextCreationConfig, @@ -1125,7 +1124,7 @@ var WebGLRenderer = new Class({ { filter = gl.LINEAR; } - else if (scaleMode === CONST.ScaleModes.NEAREST || this.config.pixelArt || !this.config.antialias) + else if (scaleMode === CONST.ScaleModes.NEAREST || !this.config.antialias) { filter = gl.NEAREST; } diff --git a/src/renderer/webgl/pipelines/TextureTintPipeline.js b/src/renderer/webgl/pipelines/TextureTintPipeline.js index 2c881b879..59424d4cd 100644 --- a/src/renderer/webgl/pipelines/TextureTintPipeline.js +++ b/src/renderer/webgl/pipelines/TextureTintPipeline.js @@ -2080,7 +2080,7 @@ var TextureTintPipeline = new Class({ this.flush(); } - var roundPixels = camera.roundPixels; + var roundPixels = this.renderer.config.roundPixels; var vertexViewF32 = this.vertexViewF32; var vertexViewU32 = this.vertexViewU32; var width = frameWidth; diff --git a/src/textures/TextureSource.js b/src/textures/TextureSource.js index 544d34322..93d9710b1 100644 --- a/src/textures/TextureSource.js +++ b/src/textures/TextureSource.js @@ -164,7 +164,7 @@ var TextureSource = new Class({ } } - if (game.config.pixelArt || !game.config.antialias) + if (!game.config.antialias) { this.setFilter(1); } From 217779604c99f2e75d3e3abd293b505bf99cad60 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Thu, 28 Jun 2018 12:59:27 +0100 Subject: [PATCH 44/48] Added tileScaleX and tileScaleY support for Tile Sprites --- CHANGELOG.md | 2 + src/gameobjects/tilesprite/TileSprite.js | 103 +++++++++++++----- .../tilesprite/TileSpriteCanvasRenderer.js | 8 +- .../tilesprite/TileSpriteWebGLRenderer.js | 25 ++++- src/renderer/webgl/WebGLRenderer.js | 8 +- .../webgl/pipelines/TextureTintPipeline.js | 98 ++++++----------- 6 files changed, 143 insertions(+), 101 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 58caa8628..39067aa3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,7 @@ There is a third game config property called `pixelArt`. If set to `true` it's t * `ScenePlugin.sleep` (and the corresponding methods in Scene Systems and the Scene Manager) now has a new optional `data` argument, which is passed to the target Scene and emitted in its 'sleep' event. * `ScenePlugin.wake` (and the corresponding methods in Scene Systems and the Scene Manager) now has a new optional `data` argument, which is passed to the target Scene and emitted in its 'wake' event. * `ScenePlugin.setActive` now has a new optional `data` argument, which is passed to the target Scene and emitted in its 'pause' or 'resume' events. +* `TileSprite.tileScaleX` and `tileScaleY` are two new properties that allow you to control the scale of the texture within the Tile Sprite. This impacts the way the repeating texture is scaled, and is independent to scaling the Tile Sprite itself. It works in both Canvas and WebGL mode. ### Updates @@ -62,6 +63,7 @@ There is a third game config property called `pixelArt`. If set to `true` it's t * If the Blitter object has no Bob's to render it will now abort immediately, avoiding several context calls in Canvas mode. * `Scene.run` will now pass the optional `data` object in all cases, no matter if it's waking, resuming or starting a Scene (thanks @rook2pawn) * `ScenePlugin.start` and `ScenePlugin.restart` will now always queue the op with the Scene Manager, regardless of the state of the Scene, in order to avoid issues where plugins carry on running for a frame before closing down. Fix #3776 (thanks @jjalonso) +* The `batchTileSprite` method has been removed from the `TextureTintPipeline` class, because it is now handled internally bu the Tile Sprite object itself. ### Bug Fixes diff --git a/src/gameobjects/tilesprite/TileSprite.js b/src/gameobjects/tilesprite/TileSprite.js index 0a7111177..2ae4734e2 100644 --- a/src/gameobjects/tilesprite/TileSprite.js +++ b/src/gameobjects/tilesprite/TileSprite.js @@ -19,7 +19,21 @@ var TileSpriteRender = require('./TileSpriteRender'); * The texture can be scrolled and scaled independently of the TileSprite itself. Textures will automatically wrap and * are designed so that you can create game backdrops using seamless textures as a source. * - * [description] + * You shouldn't ever create a TileSprite any larger than your actual screen size. If you want to create a large repeating background + * that scrolls across the whole map of your game, then you create a TileSprite that fits the screen size and then use the `tilePosition` + * property to scroll the texture as the player moves. If you create a TileSprite that is thousands of pixels in size then it will + * consume huge amounts of memory and cause performance issues. Remember: use `tilePosition` to scroll your texture and `tileScale` to + * adjust the scale of the texture - don't resize the sprite itself or make it larger than it needs. + * + * An important note about Tile Sprites and NPOT textures: Internally, TileSprite textures use GL_REPEAT to provide + * seamless repeating of the textures. This, combined with the way in which the textures are handled in WebGL, means + * they need to be POT (power-of-two) sizes in order to wrap. If you provide a NPOT (non power-of-two) texture to a + * TileSprite it will generate a POT sized canvas and draw your texture to it, scaled up to the POT size. It's then + * scaled back down again during rendering to the original dimensions. While this works, in that it allows you to use + * any size texture for a Tile Sprite, it does mean that NPOT textures are going to appear anti-aliased when rendered, + * due to the interpolation that took place when it was resized into a POT texture. This is especially visible in + * pixel art graphics. If you notice it and it becomes an issue, the only way to avoid it is to ensure that you + * provide POT textures for Tile Sprites. * * @class TileSprite * @extends Phaser.GameObjects.GameObject @@ -102,6 +116,26 @@ var TileSprite = new Class({ */ this.tilePositionY = 0; + /** + * The horizontal scale of the Tile Sprite texture. + * + * @name Phaser.GameObjects.TileSprite#tileScaleX + * @type {number} + * @default 1 + * @since 3.11.0 + */ + this.tileScaleX = 1; + + /** + * The vertical scale of the Tile Sprite texture. + * + * @name Phaser.GameObjects.TileSprite#tileScaleY + * @type {number} + * @default 1 + * @since 3.11.0 + */ + this.tileScaleY = 1; + /** * Whether the Tile Sprite has changed in some way, requiring an re-render of its tile texture. * @@ -116,9 +150,10 @@ var TileSprite = new Class({ /** * The texture that the Tile Sprite is rendered to, which is then rendered to a Scene. + * In WebGL this is a WebGLTexture. In Canvas it's a Canvas Fill Pattern. * * @name Phaser.GameObjects.TileSprite#tileTexture - * @type {?WebGLTexture} + * @type {?(WebGLTexture|CanvasPattern)} * @default null * @since 3.0.0 */ @@ -165,7 +200,7 @@ var TileSprite = new Class({ * @default null * @since 3.0.0 */ - this.canvasPattern = null; + // this.canvasPattern = null; /** * The Canvas that the TileSprite's texture is rendered to. @@ -185,6 +220,14 @@ var TileSprite = new Class({ */ this.canvasBufferCtx = this.canvasBuffer.getContext('2d'); + /** + * The previous Texture Frame being used. + * + * @name Phaser.GameObjects.Components.Texture#oldFrame + * @type {Phaser.Textures.Frame} + * @private + * @since 3.0.0 + */ this.oldFrame = null; this.updateTileTexture(); @@ -236,41 +279,41 @@ var TileSprite = new Class({ */ updateTileTexture: function () { - if (!this.dirty && this.oldFrame === this.frame) + var frame = this.frame; + + if (!this.dirty && this.oldFrame === frame) { return; } - this.oldFrame = this.frame; + this.oldFrame = frame; - this.canvasBufferCtx.clearRect(0, 0, this.canvasBuffer.width, this.canvasBuffer.height); + var ctx = this.canvasBufferCtx; + var canvas = this.canvasBuffer; - if (this.renderer.gl) + var fw = this.potWidth; + var fh = this.potHeight; + + if (!this.renderer.gl) { - this.canvasBufferCtx.drawImage( - this.frame.source.image, - this.frame.cutX, this.frame.cutY, - this.frame.cutWidth, this.frame.cutHeight, - 0, 0, - this.potWidth, this.potHeight - ); - - this.tileTexture = this.renderer.canvasToTexture(this.canvasBuffer, this.tileTexture); + fw = frame.cutWidth; + fh = frame.cutHeight; } - else - { - this.canvasBuffer.width = this.frame.cutWidth; - this.canvasBuffer.height = this.frame.cutHeight; - this.canvasBufferCtx.drawImage( - this.frame.source.image, - this.frame.cutX, this.frame.cutY, - this.frame.cutWidth, this.frame.cutHeight, - 0, 0, - this.frame.cutWidth, this.frame.cutHeight - ); - this.canvasPattern = this.canvasBufferCtx.createPattern(this.canvasBuffer, 'repeat'); - } + ctx.clearRect(0, 0, canvas.width, canvas.height); + + canvas.width = fw; + canvas.height = fh; + + ctx.drawImage( + frame.source.image, + frame.cutX, frame.cutY, + frame.cutWidth, frame.cutHeight, + 0, 0, + fw, fh + ); + + this.tileTexture = (this.renderer.gl) ? this.renderer.canvasToTexture(canvas, this.tileTexture) : ctx.createPattern(canvas, 'repeat'); this.dirty = false; }, @@ -291,7 +334,7 @@ var TileSprite = new Class({ CanvasPool.remove(this.canvasBuffer); - this.canvasPattern = null; + this.tileTexture = null; this.canvasBufferCtx = null; this.canvasBuffer = null; diff --git a/src/gameobjects/tilesprite/TileSpriteCanvasRenderer.js b/src/gameobjects/tilesprite/TileSpriteCanvasRenderer.js index dfbc7ad46..c744a5504 100644 --- a/src/gameobjects/tilesprite/TileSpriteCanvasRenderer.js +++ b/src/gameobjects/tilesprite/TileSpriteCanvasRenderer.js @@ -99,6 +99,7 @@ var TileSpriteCanvasRenderer = function (renderer, src, interpolationPercentage, if (parentMatrix !== undefined) { var matrix = parentMatrix.matrix; + ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); } @@ -116,9 +117,12 @@ var TileSpriteCanvasRenderer = function (renderer, src, interpolationPercentage, ctx.translate(-(src.originX * src.width), -(src.originY * src.height)); // Draw + + ctx.scale(src.tileScaleX, src.tileScaleY); + ctx.translate(-this.tilePositionX, -this.tilePositionY); - ctx.fillStyle = src.canvasPattern; - ctx.fillRect(this.tilePositionX, this.tilePositionY, src.width, src.height); + ctx.fillStyle = src.tileTexture; + ctx.fillRect(this.tilePositionX, this.tilePositionY, src.width / src.tileScaleX, src.height / src.tileScaleY); ctx.restore(); }; diff --git a/src/gameobjects/tilesprite/TileSpriteWebGLRenderer.js b/src/gameobjects/tilesprite/TileSpriteWebGLRenderer.js index d6d4d6369..a73ed4f51 100644 --- a/src/gameobjects/tilesprite/TileSpriteWebGLRenderer.js +++ b/src/gameobjects/tilesprite/TileSpriteWebGLRenderer.js @@ -5,6 +5,7 @@ */ var GameObject = require('../GameObject'); +var Utils = require('../../renderer/webgl/Utils'); /** * Renders this Game Object with the WebGL Renderer to the given Camera. @@ -30,7 +31,29 @@ var TileSpriteWebGLRenderer = function (renderer, src, interpolationPercentage, src.updateTileTexture(); - this.pipeline.batchTileSprite(this, camera, parentMatrix); + var getTint = Utils.getTintAppendFloatAlpha; + + this.pipeline.batchTexture( + src, + src.tileTexture, + src.frame.width * src.tileScaleX, src.frame.height * src.tileScaleY, + src.x, src.y, + src.width, src.height, + src.scaleX, src.scaleY, + src.rotation, + src.flipX, src.flipY, + src.scrollFactorX, src.scrollFactorY, + src.originX * src.width, src.originY * src.height, + 0, 0, src.width, src.height, + getTint(src._tintTL, camera.alpha * src._alphaTL), + getTint(src._tintTR, camera.alpha * src._alphaTR), + getTint(src._tintBL, camera.alpha * src._alphaBL), + getTint(src._tintBR, camera.alpha * src._alphaBR), + (src.tilePositionX % src.frame.width) / src.frame.width, + (src.tilePositionY % src.frame.height) / src.frame.height, + camera, + parentMatrix + ); }; module.exports = TileSpriteWebGLRenderer; diff --git a/src/renderer/webgl/WebGLRenderer.js b/src/renderer/webgl/WebGLRenderer.js index 6aef8b1f0..9f3c043b5 100644 --- a/src/renderer/webgl/WebGLRenderer.js +++ b/src/renderer/webgl/WebGLRenderer.js @@ -1120,14 +1120,10 @@ var WebGLRenderer = new Class({ wrap = gl.REPEAT; } - if (scaleMode === CONST.ScaleModes.LINEAR) + if (scaleMode === CONST.ScaleModes.LINEAR && this.config.antialias) { filter = gl.LINEAR; } - else if (scaleMode === CONST.ScaleModes.NEAREST || !this.config.antialias) - { - filter = gl.NEAREST; - } if (!source && typeof width === 'number' && typeof height === 'number') { @@ -1157,7 +1153,7 @@ var WebGLRenderer = new Class({ * @param {object} pixels - pixel data * @param {integer} width - Width of the texture in pixels * @param {integer} height - Height of the texture in pixels - * @param {boolean} pma - Does the texture hace premultiplied alpha. + * @param {boolean} pma - Does the texture have premultiplied alpha? * * @return {WebGLTexture} Raw WebGLTexture */ diff --git a/src/renderer/webgl/pipelines/TextureTintPipeline.js b/src/renderer/webgl/pipelines/TextureTintPipeline.js index 59424d4cd..3e34b5304 100644 --- a/src/renderer/webgl/pipelines/TextureTintPipeline.js +++ b/src/renderer/webgl/pipelines/TextureTintPipeline.js @@ -800,24 +800,15 @@ var TextureTintPipeline = new Class({ { this.flush(); } - - var roundPixels = camera.roundPixels; - var getTint = Utils.getTintAppendFloatAlpha; - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var cameraMatrix = camera.matrix.matrix; + var frame = sprite.frame; var texture = frame.texture.source[frame.sourceIndex].glTexture; + var getTint = Utils.getTintAppendFloatAlpha; var forceFlipY = (texture.isRenderTexture ? true : false); var flipX = sprite.flipX; var flipY = sprite.flipY ^ forceFlipY; var uvs = frame.uvs; - var width = frame.width * (flipX ? -1.0 : 1.0); - var height = frame.height * (flipY ? -1.0 : 1.0); - var x = -sprite.displayOriginX + frame.x + ((frame.width) * (flipX ? 1.0 : 0.0)); - var y = -sprite.displayOriginY + frame.y + ((frame.height) * (flipY ? 1.0 : 0.0)); - var xw = (roundPixels ? (x|0) : x) + width; - var yh = (roundPixels ? (y|0) : y) + height; + var scaleX = sprite.scaleX; var scaleY = sprite.scaleY; var rotation = sprite.rotation; @@ -829,6 +820,17 @@ var TextureTintPipeline = new Class({ var tintTR = sprite._tintTR; var tintBL = sprite._tintBL; var tintBR = sprite._tintBR; + + var roundPixels = camera.roundPixels; + var vertexViewF32 = this.vertexViewF32; + var vertexViewU32 = this.vertexViewU32; + var cameraMatrix = camera.matrix.matrix; + var width = frame.width * (flipX ? -1.0 : 1.0); + var height = frame.height * (flipY ? -1.0 : 1.0); + var x = -sprite.displayOriginX + frame.x + ((frame.width) * (flipX ? 1.0 : 0.0)); + var y = -sprite.displayOriginY + frame.y + ((frame.height) * (flipY ? 1.0 : 0.0)); + var xw = (roundPixels ? (x | 0) : x) + width; + var yh = (roundPixels ? (y | 0) : y) + height; var sr = Math.sin(rotation); var cr = Math.cos(rotation); var sra = cr * scaleX; @@ -896,7 +898,6 @@ var TextureTintPipeline = new Class({ var vTintTR = getTint(tintTR, alphaTR); var vTintBL = getTint(tintBL, alphaBL); var vTintBR = getTint(tintBR, alphaBR); - var vertexOffset = 0; if (roundPixels) { @@ -912,33 +913,38 @@ var TextureTintPipeline = new Class({ this.setTexture2D(texture, 0); - vertexOffset = this.vertexCount * this.vertexComponentCount; + var vertexOffset = this.vertexCount * this.vertexComponentCount; vertexViewF32[vertexOffset + 0] = tx0; vertexViewF32[vertexOffset + 1] = ty0; vertexViewF32[vertexOffset + 2] = uvs.x0; vertexViewF32[vertexOffset + 3] = uvs.y0; vertexViewU32[vertexOffset + 4] = vTintTL; + vertexViewF32[vertexOffset + 5] = tx1; vertexViewF32[vertexOffset + 6] = ty1; vertexViewF32[vertexOffset + 7] = uvs.x1; vertexViewF32[vertexOffset + 8] = uvs.y1; vertexViewU32[vertexOffset + 9] = vTintBL; + vertexViewF32[vertexOffset + 10] = tx2; vertexViewF32[vertexOffset + 11] = ty2; vertexViewF32[vertexOffset + 12] = uvs.x2; vertexViewF32[vertexOffset + 13] = uvs.y2; vertexViewU32[vertexOffset + 14] = vTintBR; + vertexViewF32[vertexOffset + 15] = tx0; vertexViewF32[vertexOffset + 16] = ty0; vertexViewF32[vertexOffset + 17] = uvs.x0; vertexViewF32[vertexOffset + 18] = uvs.y0; vertexViewU32[vertexOffset + 19] = vTintTL; + vertexViewF32[vertexOffset + 20] = tx2; vertexViewF32[vertexOffset + 21] = ty2; vertexViewF32[vertexOffset + 22] = uvs.x2; vertexViewF32[vertexOffset + 23] = uvs.y2; vertexViewU32[vertexOffset + 24] = vTintBR; + vertexViewF32[vertexOffset + 25] = tx3; vertexViewF32[vertexOffset + 26] = ty3; vertexViewF32[vertexOffset + 27] = uvs.x3; @@ -1800,43 +1806,6 @@ var TextureTintPipeline = new Class({ } }, - /** - * Batches TileSprite game object - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchTileSprite - * @since 3.0.0 - * - * @param {Phaser.GameObjects.TileSprite} tileSprite - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - */ - batchTileSprite: function (tileSprite, camera, parentTransformMatrix) - { - var getTint = Utils.getTintAppendFloatAlpha; - - this.batchTexture( - tileSprite, - tileSprite.tileTexture, - tileSprite.frame.width, tileSprite.frame.height, - tileSprite.x, tileSprite.y, - tileSprite.width, tileSprite.height, - tileSprite.scaleX, tileSprite.scaleY, - tileSprite.rotation, - tileSprite.flipX, tileSprite.flipY, - tileSprite.scrollFactorX, tileSprite.scrollFactorY, - tileSprite.originX * tileSprite.width, tileSprite.originY * tileSprite.height, - 0, 0, tileSprite.width, tileSprite.height, - getTint(tileSprite._tintTL, camera.alpha * tileSprite._alphaTL), - getTint(tileSprite._tintTR, camera.alpha * tileSprite._alphaTR), - getTint(tileSprite._tintBL, camera.alpha * tileSprite._alphaBL), - getTint(tileSprite._tintBR, camera.alpha * tileSprite._alphaBR), - (tileSprite.tilePositionX % tileSprite.frame.width) / tileSprite.frame.width, - (tileSprite.tilePositionY % tileSprite.frame.height) / tileSprite.frame.height, - camera, - parentTransformMatrix - ); - }, - /** * Generic function for batching a textured quad * @@ -1914,18 +1883,18 @@ var TextureTintPipeline = new Class({ var height = srcHeight * (flipY ? -1.0 : 1.0); var x = -displayOriginX + ((srcWidth) * (flipX ? 1.0 : 0.0)); var y = -displayOriginY + ((srcHeight) * (flipY ? 1.0 : 0.0)); - var xw = x + width; - var yh = y + height; - var translateX = srcX; - var translateY = srcY; + // var x = -displayOriginX + frameX + ((frameWidth) * (flipX ? 1.0 : 0.0)); + // var y = -displayOriginY + frameY + ((frameHeight) * (flipY ? 1.0 : 0.0)); + var xw = (roundPixels ? (x | 0) : x) + width; + var yh = (roundPixels ? (y | 0) : y) + height; var sr = Math.sin(rotation); var cr = Math.cos(rotation); var sra = cr * scaleX; var srb = sr * scaleX; var src = -sr * scaleY; var srd = cr * scaleY; - var sre = translateX; - var srf = translateY; + var sre = srcX; + var srf = srcY; var cma = cameraMatrix[0]; var cmb = cameraMatrix[1]; var cmc = cameraMatrix[2]; @@ -1981,15 +1950,11 @@ var TextureTintPipeline = new Class({ var ty2 = xw * mvb + yh * mvd + mvf; var tx3 = xw * mva + y * mvc + mve; var ty3 = xw * mvb + y * mvd + mvf; - var vertexOffset = 0; + var u0 = (frameX / textureWidth) + uOffset; var v0 = (frameY / textureHeight) + vOffset; var u1 = (frameX + frameWidth) / textureWidth + uOffset; var v1 = (frameY + frameHeight) / textureHeight + vOffset; - - this.setTexture2D(texture, 0); - - vertexOffset = this.vertexCount * this.vertexComponentCount; if (roundPixels) { @@ -2003,31 +1968,40 @@ var TextureTintPipeline = new Class({ ty3 |= 0; } + this.setTexture2D(texture, 0); + + var vertexOffset = this.vertexCount * this.vertexComponentCount; + vertexViewF32[vertexOffset + 0] = tx0; vertexViewF32[vertexOffset + 1] = ty0; vertexViewF32[vertexOffset + 2] = u0; vertexViewF32[vertexOffset + 3] = v0; vertexViewU32[vertexOffset + 4] = tintTL; + vertexViewF32[vertexOffset + 5] = tx1; vertexViewF32[vertexOffset + 6] = ty1; vertexViewF32[vertexOffset + 7] = u0; vertexViewF32[vertexOffset + 8] = v1; vertexViewU32[vertexOffset + 9] = tintTR; + vertexViewF32[vertexOffset + 10] = tx2; vertexViewF32[vertexOffset + 11] = ty2; vertexViewF32[vertexOffset + 12] = u1; vertexViewF32[vertexOffset + 13] = v1; vertexViewU32[vertexOffset + 14] = tintBL; + vertexViewF32[vertexOffset + 15] = tx0; vertexViewF32[vertexOffset + 16] = ty0; vertexViewF32[vertexOffset + 17] = u0; vertexViewF32[vertexOffset + 18] = v0; vertexViewU32[vertexOffset + 19] = tintTL; + vertexViewF32[vertexOffset + 20] = tx2; vertexViewF32[vertexOffset + 21] = ty2; vertexViewF32[vertexOffset + 22] = u1; vertexViewF32[vertexOffset + 23] = v1; vertexViewU32[vertexOffset + 24] = tintBL; + vertexViewF32[vertexOffset + 25] = tx3; vertexViewF32[vertexOffset + 26] = ty3; vertexViewF32[vertexOffset + 27] = u1; From 39c3866179802cea2983ec37caa6ab186283bf27 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Thu, 28 Jun 2018 13:07:59 +0100 Subject: [PATCH 45/48] lint fix --- src/renderer/webgl/pipelines/TextureTintPipeline.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/renderer/webgl/pipelines/TextureTintPipeline.js b/src/renderer/webgl/pipelines/TextureTintPipeline.js index 3e34b5304..d71e33248 100644 --- a/src/renderer/webgl/pipelines/TextureTintPipeline.js +++ b/src/renderer/webgl/pipelines/TextureTintPipeline.js @@ -1883,8 +1883,10 @@ var TextureTintPipeline = new Class({ var height = srcHeight * (flipY ? -1.0 : 1.0); var x = -displayOriginX + ((srcWidth) * (flipX ? 1.0 : 0.0)); var y = -displayOriginY + ((srcHeight) * (flipY ? 1.0 : 0.0)); + // var x = -displayOriginX + frameX + ((frameWidth) * (flipX ? 1.0 : 0.0)); // var y = -displayOriginY + frameY + ((frameHeight) * (flipY ? 1.0 : 0.0)); + var xw = (roundPixels ? (x | 0) : x) + width; var yh = (roundPixels ? (y | 0) : y) + height; var sr = Math.sin(rotation); From f97ce72e167640b76746b9d924a62d4a240db223 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Thu, 28 Jun 2018 14:17:04 +0100 Subject: [PATCH 46/48] Added the Mask compontent to Container. It worked without it, but this brings it in-line with the documentation and other Game Objects. Fix #3797 --- CHANGELOG.md | 3 ++- src/gameobjects/container/Container.js | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 39067aa3b..a17f30da2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -63,7 +63,7 @@ There is a third game config property called `pixelArt`. If set to `true` it's t * If the Blitter object has no Bob's to render it will now abort immediately, avoiding several context calls in Canvas mode. * `Scene.run` will now pass the optional `data` object in all cases, no matter if it's waking, resuming or starting a Scene (thanks @rook2pawn) * `ScenePlugin.start` and `ScenePlugin.restart` will now always queue the op with the Scene Manager, regardless of the state of the Scene, in order to avoid issues where plugins carry on running for a frame before closing down. Fix #3776 (thanks @jjalonso) -* The `batchTileSprite` method has been removed from the `TextureTintPipeline` class, because it is now handled internally bu the Tile Sprite object itself. +* The `batchTileSprite` method has been removed from the `TextureTintPipeline` class, because it is now handled internally by the Tile Sprite object itself. ### Bug Fixes @@ -81,6 +81,7 @@ There is a third game config property called `pixelArt`. If set to `true` it's t * TileSprite was using the Size compontent instead of ComputedSize, meaning its `getBounds` and `displayWidth` and `displayHeight` results were incorrect. Fix #3789 (thanks @jjalonso) * ArrayUtils.AddAt didn't calculate the array offset correctly if you passed an array in to be merged with an existing array. This also caused Container.addAt to fail if an array was passed to it. Fix #3788 (thanks @jjalonso) * The `Pointer.camera` property would only be set if there was a viable Game Object in the camera view. Now it is set regardless, to always be the Camera the Pointer interacted with. +* Added the Mask compontent to Container. It worked without it, but this brings it in-line with the documentation and other Game Objects. Fix #3797 (thanks @zilbuz) ### Examples, Documentation and TypeScript diff --git a/src/gameobjects/container/Container.js b/src/gameobjects/container/Container.js index b89ad5180..67b2de884 100644 --- a/src/gameobjects/container/Container.js +++ b/src/gameobjects/container/Container.js @@ -79,6 +79,7 @@ var Container = new Class({ Components.BlendMode, Components.ComputedSize, Components.Depth, + Components.Mask, Components.ScrollFactor, Components.Transform, Components.Visible, From b57d94ae33c00f12b6aef74144b86b5c2a89c7d6 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Fri, 29 Jun 2018 01:07:14 +0100 Subject: [PATCH 47/48] Typo fixes --- CHANGELOG.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a17f30da2..ea4dddb42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,7 @@ * `Camera.setBounds` has a new optional argument `centerOn`. If specified it will automatically center the camera on the new bounds given. * The Camera will no longer stutter when following Game Objects at high zoom levels. * `Camera._id` has been renamed to `Camera.id`, a read-only bitmask used for camera exclusion from Game Objects. -* The Camera Manager `cameraPool` has been removed entirely. It was mostly pointless in practise as Cameras are not regenerated frequently enough to need pooling. It also didn't maintain the bitmask list correctly before. +* The Camera Manager `cameraPool` has been removed entirely. It was mostly pointless in practice as Cameras are not regenerated frequently enough to need pooling. It also didn't maintain the bitmask list correctly before. * `CameraManager.resetAll` now destroys all current Cameras, resets the camera ID marker to 1 and adds a single new Camera. * `CameraManager.currentCameraId` has been removed. IDs are assigned more intelligently now, via the `getNextID` internal method. * `CameraManager.addExisting` no longer needs to be passed a Camera that already exists in the pool (as the pool has been removed), meaning you can now create your own Cameras and pass them to `addExisting` and have them treated as normal cameras and not be ignored by the manager. They are also assigned a proper ID when added. @@ -78,10 +78,10 @@ There is a third game config property called `pixelArt`. If set to `true` it's t * `GameObject.disableInteractive` was toggling input. Every second call would turn the input back on (thanks @TadejZupancic) * The position of the TilemapLayer wasn't taken into account when culling tiles for the Camera. It's now calculated as part of the cull flow (thanks @Upperfoot) * Fix extra argument passing in Array.Each (thanks @samme) -* TileSprite was using the Size compontent instead of ComputedSize, meaning its `getBounds` and `displayWidth` and `displayHeight` results were incorrect. Fix #3789 (thanks @jjalonso) -* ArrayUtils.AddAt didn't calculate the array offset correctly if you passed an array in to be merged with an existing array. This also caused Container.addAt to fail if an array was passed to it. Fix #3788 (thanks @jjalonso) +* TileSprite was using the Size component instead of ComputedSize, meaning its `getBounds` and `displayWidth` and `displayHeight` results were incorrect. Fix #3789 (thanks @jjalonso) +* `ArrayUtils.AddAt` didn't calculate the array offset correctly if you passed an array in to be merged with an existing array. This also caused Container.addAt to fail if an array was passed to it. Fix #3788 (thanks @jjalonso) * The `Pointer.camera` property would only be set if there was a viable Game Object in the camera view. Now it is set regardless, to always be the Camera the Pointer interacted with. -* Added the Mask compontent to Container. It worked without it, but this brings it in-line with the documentation and other Game Objects. Fix #3797 (thanks @zilbuz) +* Added the Mask component to Container. It worked without it, but this brings it in-line with the documentation and other Game Objects. Fix #3797 (thanks @zilbuz) ### Examples, Documentation and TypeScript @@ -89,7 +89,7 @@ My thanks to the following for helping with the Phaser 3 Examples, Docs and Type @DannyT @squilibob @dvdbrink @t1gu1 @cyantree @DrevanTonder @mikewesthad -Also, a special mention to @andygroff for his excellent work enhancing the search box on the examples site. +Also, a special mention to @andygroff for his excellent work enhancing the search box on the examples site, and @hexus for his assistance completing the documentation for the Game Objects. ## Version 3.10.1 - Hayashi - 13th June 2018 From e22b1a7b9cad48987aeb756eb2dd9cf3e5f987ca Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Fri, 29 Jun 2018 12:33:44 +0100 Subject: [PATCH 48/48] Removed stubs from pipelines --- .../webgl/pipelines/FlatTintPipeline.js | 153 +++--------------- .../webgl/pipelines/TextureTintPipeline.js | 14 -- 2 files changed, 20 insertions(+), 147 deletions(-) diff --git a/src/renderer/webgl/pipelines/FlatTintPipeline.js b/src/renderer/webgl/pipelines/FlatTintPipeline.js index 6c18427ec..9063e3814 100644 --- a/src/renderer/webgl/pipelines/FlatTintPipeline.js +++ b/src/renderer/webgl/pipelines/FlatTintPipeline.js @@ -133,7 +133,7 @@ var FlatTintPipeline = new Class({ ]; /** - * Used internally by for triangulating a polyong + * Used internally for triangulating a polygon * * @name Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#polygonCache * @type {array} @@ -245,18 +245,23 @@ var FlatTintPipeline = new Class({ vertexViewF32[vertexOffset + 0] = tx0; vertexViewF32[vertexOffset + 1] = ty0; vertexViewU32[vertexOffset + 2] = tint; + vertexViewF32[vertexOffset + 3] = tx1; vertexViewF32[vertexOffset + 4] = ty1; vertexViewU32[vertexOffset + 5] = tint; + vertexViewF32[vertexOffset + 6] = tx2; vertexViewF32[vertexOffset + 7] = ty2; vertexViewU32[vertexOffset + 8] = tint; + vertexViewF32[vertexOffset + 9] = tx0; vertexViewF32[vertexOffset + 10] = ty0; vertexViewU32[vertexOffset + 11] = tint; + vertexViewF32[vertexOffset + 12] = tx2; vertexViewF32[vertexOffset + 13] = ty2; vertexViewU32[vertexOffset + 14] = tint; + vertexViewF32[vertexOffset + 15] = tx3; vertexViewF32[vertexOffset + 16] = ty3; vertexViewU32[vertexOffset + 17] = tint; @@ -326,9 +331,11 @@ var FlatTintPipeline = new Class({ vertexViewF32[vertexOffset + 0] = tx0; vertexViewF32[vertexOffset + 1] = ty0; vertexViewU32[vertexOffset + 2] = tint; + vertexViewF32[vertexOffset + 3] = tx1; vertexViewF32[vertexOffset + 4] = ty1; vertexViewU32[vertexOffset + 5] = tint; + vertexViewF32[vertexOffset + 6] = tx2; vertexViewF32[vertexOffset + 7] = ty2; vertexViewU32[vertexOffset + 8] = tint; @@ -487,9 +494,11 @@ var FlatTintPipeline = new Class({ vertexViewF32[vertexOffset + 0] = tx0; vertexViewF32[vertexOffset + 1] = ty0; vertexViewU32[vertexOffset + 2] = tint; + vertexViewF32[vertexOffset + 3] = tx1; vertexViewF32[vertexOffset + 4] = ty1; vertexViewU32[vertexOffset + 5] = tint; + vertexViewF32[vertexOffset + 6] = tx2; vertexViewF32[vertexOffset + 7] = ty2; vertexViewU32[vertexOffset + 8] = tint; @@ -571,18 +580,23 @@ var FlatTintPipeline = new Class({ vertexViewF32[vertexOffset + 0] = last[3 * 2 + 0]; vertexViewF32[vertexOffset + 1] = last[3 * 2 + 1]; vertexViewU32[vertexOffset + 2] = getTint(last[3 * 2 + 2], lineAlpha); + vertexViewF32[vertexOffset + 3] = last[3 * 0 + 0]; vertexViewF32[vertexOffset + 4] = last[3 * 0 + 1]; vertexViewU32[vertexOffset + 5] = getTint(last[3 * 0 + 2], lineAlpha); + vertexViewF32[vertexOffset + 6] = curr[3 * 3 + 0]; vertexViewF32[vertexOffset + 7] = curr[3 * 3 + 1]; vertexViewU32[vertexOffset + 8] = getTint(curr[3 * 3 + 2], lineAlpha); + vertexViewF32[vertexOffset + 9] = last[3 * 0 + 0]; vertexViewF32[vertexOffset + 10] = last[3 * 0 + 1]; vertexViewU32[vertexOffset + 11] = getTint(last[3 * 0 + 2], lineAlpha); + vertexViewF32[vertexOffset + 12] = last[3 * 2 + 0]; vertexViewF32[vertexOffset + 13] = last[3 * 2 + 1]; vertexViewU32[vertexOffset + 14] = getTint(last[3 * 2 + 2], lineAlpha); + vertexViewF32[vertexOffset + 15] = curr[3 * 1 + 0]; vertexViewF32[vertexOffset + 16] = curr[3 * 1 + 1]; vertexViewU32[vertexOffset + 17] = getTint(curr[3 * 1 + 2], lineAlpha); @@ -675,18 +689,23 @@ var FlatTintPipeline = new Class({ vertexViewF32[vertexOffset + 0] = x0; vertexViewF32[vertexOffset + 1] = y0; vertexViewU32[vertexOffset + 2] = bTint; + vertexViewF32[vertexOffset + 3] = x1; vertexViewF32[vertexOffset + 4] = y1; vertexViewU32[vertexOffset + 5] = aTint; + vertexViewF32[vertexOffset + 6] = x2; vertexViewF32[vertexOffset + 7] = y2; vertexViewU32[vertexOffset + 8] = bTint; + vertexViewF32[vertexOffset + 9] = x1; vertexViewF32[vertexOffset + 10] = y1; vertexViewU32[vertexOffset + 11] = aTint; + vertexViewF32[vertexOffset + 12] = x3; vertexViewF32[vertexOffset + 13] = y3; vertexViewU32[vertexOffset + 14] = aTint; + vertexViewF32[vertexOffset + 15] = x2; vertexViewF32[vertexOffset + 16] = y2; vertexViewU32[vertexOffset + 17] = bTint; @@ -1137,138 +1156,6 @@ var FlatTintPipeline = new Class({ break; } } - }, - - // Stubs - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#drawStaticTilemapLayer - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.StaticTilemapLayer} tilemap - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - drawStaticTilemapLayer: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#drawEmitterManager - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.ParticleEmitterManager} emitterManager - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - drawEmitterManager: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#drawBlitter - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Blitter} blitter - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - drawBlitter: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchSprite - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Sprite} sprite - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - batchSprite: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchMesh - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Mesh} mesh - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - batchMesh: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchBitmapText - * @since 3.0.0 - * - * @param {Phaser.GameObjects.BitmapText} bitmapText - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - batchBitmapText: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchDynamicBitmapText - * @since 3.0.0 - * - * @param {Phaser.GameObjects.DynamicBitmapText} bitmapText - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - batchDynamicBitmapText: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchText - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Text} text - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - batchText: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchDynamicTilemapLayer - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.DynamicTilemapLayer} tilemapLayer - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - batchDynamicTilemapLayer: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchTileSprite - * @since 3.0.0 - * - * @param {Phaser.GameObjects.TileSprite} tileSprite - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - batchTileSprite: function () - { } }); diff --git a/src/renderer/webgl/pipelines/TextureTintPipeline.js b/src/renderer/webgl/pipelines/TextureTintPipeline.js index d71e33248..4f79de15b 100644 --- a/src/renderer/webgl/pipelines/TextureTintPipeline.js +++ b/src/renderer/webgl/pipelines/TextureTintPipeline.js @@ -2162,20 +2162,6 @@ var TextureTintPipeline = new Class({ // Force an immediate draw this.flush(); - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchGraphics - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Graphics} graphics - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - batchGraphics: function () - { - // Stub } });