From 44e4e7162da0d4b570f6bd623b31cc45a377925f Mon Sep 17 00:00:00 2001 From: Polar stoat Date: Fri, 20 Jul 2018 11:55:39 +0100 Subject: [PATCH 1/7] Add AnimationManager.generateFrameNumbers documentation --- src/animations/AnimationManager.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/animations/AnimationManager.js b/src/animations/AnimationManager.js index 61eb8b67b..780c66f27 100644 --- a/src/animations/AnimationManager.js +++ b/src/animations/AnimationManager.js @@ -319,23 +319,23 @@ var AnimationManager = new Class({ /** * @typedef {object} GenerateFrameNumbersConfig * - * @property {integer} [start=0] - [description] - * @property {integer} [end=-1] - [description] - * @property {boolean} [first=false] - [description] - * @property {AnimationFrameConfig[]} [outputArray=[]] - [description] - * @property {boolean} [frames=false] - [description] + * @property {integer} [start=0] - The starting frame of the animation + * @property {integer} [end=-1] - The ending frame of the animation + * @property {boolean|integer} [first=false] - A frame to put at the beginning of the animation, before `start` or `outputArray` or `frames` + * @property {AnimationFrameConfig[]} [outputArray=[]] - An array to concatenate the output onto + * @property {boolean|integer[]} [frames=false] - A custom sequence of frames */ /** - * [description] + * Generates an array of {@link AnimationFrameConfig} objects from a texture key and configuration object * * @method Phaser.Animations.AnimationManager#generateFrameNumbers * @since 3.0.0 * - * @param {string} key - [description] - * @param {GenerateFrameNumbersConfig} config - [description] + * @param {string} key - The key for the texture containing the animation frames + * @param {GenerateFrameNumbersConfig} config - The configuration object for the animation frames * - * @return {AnimationFrameConfig[]} [description] + * @return {AnimationFrameConfig[]} The array of {@link AnimationFrameConfig} objects */ generateFrameNumbers: function (key, config) { From beaedc12e8a489bc187908e3ae2898b59adc8537 Mon Sep 17 00:00:00 2001 From: Polar stoat Date: Tue, 31 Jul 2018 20:36:54 +0100 Subject: [PATCH 2/7] Fix documentation formatting Add fullstops to end of each line Fix JSDoc formatting for properties that take multiple types --- src/animations/AnimationManager.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/animations/AnimationManager.js b/src/animations/AnimationManager.js index 780c66f27..d8d20d866 100644 --- a/src/animations/AnimationManager.js +++ b/src/animations/AnimationManager.js @@ -319,23 +319,23 @@ var AnimationManager = new Class({ /** * @typedef {object} GenerateFrameNumbersConfig * - * @property {integer} [start=0] - The starting frame of the animation - * @property {integer} [end=-1] - The ending frame of the animation - * @property {boolean|integer} [first=false] - A frame to put at the beginning of the animation, before `start` or `outputArray` or `frames` - * @property {AnimationFrameConfig[]} [outputArray=[]] - An array to concatenate the output onto - * @property {boolean|integer[]} [frames=false] - A custom sequence of frames + * @property {integer} [start=0] - The starting frame of the animation. + * @property {integer} [end=-1] - The ending frame of the animation. + * @property {(boolean|integer)} [first=false] - A frame to put at the beginning of the animation, before `start` or `outputArray` or `frames`. + * @property {AnimationFrameConfig[]} [outputArray=[]] - An array to concatenate the output onto. + * @property {(boolean|integer[])} [frames=false] - A custom sequence of frames. */ /** - * Generates an array of {@link AnimationFrameConfig} objects from a texture key and configuration object + * Generates an array of {@link AnimationFrameConfig} objects from a texture key and configuration object. * * @method Phaser.Animations.AnimationManager#generateFrameNumbers * @since 3.0.0 * - * @param {string} key - The key for the texture containing the animation frames - * @param {GenerateFrameNumbersConfig} config - The configuration object for the animation frames + * @param {string} key - The key for the texture containing the animation frames. + * @param {GenerateFrameNumbersConfig} config - The configuration object for the animation frames. * - * @return {AnimationFrameConfig[]} The array of {@link AnimationFrameConfig} objects + * @return {AnimationFrameConfig[]} The array of {@link AnimationFrameConfig} objects. */ generateFrameNumbers: function (key, config) { From 7c525b00fad8f7b3385754fb5156c0466b5981f9 Mon Sep 17 00:00:00 2001 From: Jonan Scheffler Date: Tue, 7 Aug 2018 14:25:48 -0700 Subject: [PATCH 3/7] Correct Konami code in createCombo documentation. --- src/input/keyboard/KeyboardPlugin.js | 4 ++-- src/input/keyboard/combo/KeyCombo.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/input/keyboard/KeyboardPlugin.js b/src/input/keyboard/KeyboardPlugin.js index 9813ee52c..c38cb9d52 100644 --- a/src/input/keyboard/KeyboardPlugin.js +++ b/src/input/keyboard/KeyboardPlugin.js @@ -450,11 +450,11 @@ var KeyboardPlugin = new Class({ * An array of either integers (key codes) or strings, or a mixture of both * An array of objects (such as Key objects) with a public 'keyCode' property * - * For example, to listen for the Konami code (up, up, up, down, down, down, left, left, left, right, right, right) + * For example, to listen for the Konami code (up, up, down, down, left, right, left, right, b, a, enter) * you could pass the following array of key codes: * * ```javascript - * this.input.keyboard.createCombo([ 38, 38, 38, 40, 40, 40, 37, 37, 37, 39, 39, 39 ], { resetOnMatch: true }); + * this.input.keyboard.createCombo([ 38, 38, 40, 40, 37, 39, 37, 39, 66, 65, 13 ], { resetOnMatch: true }); * * this.input.keyboard.on('keycombomatch', function (event) { * console.log('Konami Code entered!'); diff --git a/src/input/keyboard/combo/KeyCombo.js b/src/input/keyboard/combo/KeyCombo.js index ea09a9ac5..398aef50d 100644 --- a/src/input/keyboard/combo/KeyCombo.js +++ b/src/input/keyboard/combo/KeyCombo.js @@ -35,11 +35,11 @@ var ResetKeyCombo = require('./ResetKeyCombo'); * An array of either integers (key codes) or strings, or a mixture of both * An array of objects (such as Key objects) with a public 'keyCode' property * - * For example, to listen for the Konami code (up, up, up, down, down, down, left, left, left, right, right, right) + * For example, to listen for the Konami code (up, up, down, down, left, right, left, right, b, a, enter) * you could pass the following array of key codes: * * ```javascript - * this.input.keyboard.createCombo([ 38, 38, 38, 40, 40, 40, 37, 37, 37, 39, 39, 39 ], { resetOnMatch: true }); + * this.input.keyboard.createCombo([ 38, 38, 40, 40, 37, 39, 37, 39, 66, 65, 13 ], { resetOnMatch: true }); * * this.input.keyboard.on('keycombomatch', function (event) { * console.log('Konami Code entered!'); From fe748e9dc7bdf477155ee6f43402d66aeb20d34a Mon Sep 17 00:00:00 2001 From: Eirik S Korsnes Date: Sun, 12 Aug 2018 12:19:48 +0200 Subject: [PATCH 4/7] - wrote dot-notated config properties as seperate typedefs - add some missing properties --- src/boot/Config.js | 120 +++++++++++++++++++++++++++++++-------------- 1 file changed, 84 insertions(+), 36 deletions(-) diff --git a/src/boot/Config.js b/src/boot/Config.js index af8abf163..b62d3c403 100644 --- a/src/boot/Config.js +++ b/src/boot/Config.js @@ -26,6 +26,50 @@ var ValueToColor = require('../display/color/ValueToColor'); * @param {Phaser.Game} game - [description] */ +/** + * @typedef {object} InputConfig + * + * @property {(boolean|KeyboardInputConfig)} [keyboard=true] - [description] + * @property {(boolean|MouseInputConfig)} [mouse=true] - [description] + * @property {(boolean|TouchInputConfig)} [touch=true] - [description] + * @property {(boolean|GamepadInputConfig)} [gamepad=false] - [description] + * @property {integer} [activePointers=1] - [description] + */ + +/** + * @typedef {object} MouseInputConfig + * + * @property {*} [target=null] - [description] + * @property {boolean} [capture=true] - [description] + */ + +/** + * @typedef {object} KeyboardInputConfig + * + * @property {*} [target=window] - [description] + */ + +/** + * @typedef {object} TouchInputConfig + * + * @property {*} [target=null] - [description] + * @property {boolean} [capture=true] - [description] + */ + +/** + * @typedef {object} GamepadInputConfig + * + * @property {*} [target=window] - [description] + */ + +/** + * @typedef {object} BannerConfig + * + * @property {boolean} [hidePhaser=false] - [description] + * @property {string} [text='#ffffff'] - [description] + * @property {string[]} [background] - [description] + */ + /** * @typedef {object} FPSConfig * @@ -36,6 +80,22 @@ var ValueToColor = require('../display/color/ValueToColor'); * @property {integer} [panicMax=120] - [description] */ +/** + * @typedef {object} RenderConfig + * + * @property {boolean} [antialias=true] - [description] + * @property {boolean} [pixelArt=false] - [description] + * @property {boolean} [autoResize=false] - [description] + * @property {boolean} [roundPixels=false] - [description] + * @property {boolean} [transparent=false] - [description] + * @property {boolean} [clearBeforeRender=true] - [description] + * @property {boolean} [premultipliedAlpha=true] - [description] + * @property {boolean} [preserveDrawingBuffer=false] - [description] + * @property {boolean} [failIfMajorPerformanceCaveat=false] - [description] + * @property {string} [powerPreference='default'] - "high-performance", "low-power" or "default" + * @property {integer} [batchSize=2000] - The default WebGL batch size. + */ + /** * @typedef {object} ScaleConfig * @@ -51,6 +111,13 @@ var ValueToColor = require('../display/color/ValueToColor'); * @property {integer} [maxHeight] - The maximum height the canvas can be scaled up to. */ +/** + * @typedef {object} CallbacksConfig + * + * @property {BootCallback} [preBoot=NOOP] - [description] + * @property {BootCallback} [postBoot=NOOP] - [description] + */ + /** * @typedef {object} LoaderConfig * @@ -72,9 +139,16 @@ var ValueToColor = require('../display/color/ValueToColor'); * @property {boolean} [behindCanvas=false] - Place the DOM Container behind the Phaser Canvas. The default is to place it over the Canvas. */ -/** +/** + * @typedef {object} ImagesConfig + * + * @property {string} [default] - [description] + * @property {string} [missing] - [description] + */ + +/** * @typedef {object} PluginObjectItem - * + * * @property {string} [key] - [description] * @property {*} [plugin] - [description] * @property {boolean} [start] - [description] @@ -83,9 +157,9 @@ var ValueToColor = require('../display/color/ValueToColor'); * @property {*} [data] - [description] */ -/** +/** * @typedef {object} PluginObject - * + * * @property {PluginObjectItem[]} [global=null] - [description] * @property {PluginObjectItem[]} [scene=null] - [description] * @property {Array} [default=[]] - [description] @@ -110,42 +184,16 @@ var ValueToColor = require('../display/color/ValueToColor'); * @property {string} [url='http://phaser.io'] - [description] * @property {string} [version=''] - [description] * @property {boolean} [autoFocus=true] - Automatically call window.focus() when the game boots. - * @property {(boolean|object)} [input] - [description] - * @property {boolean} [input.keyboard=true] - [description] - * @property {*} [input.keyboard.target=window] - [description] - * @property {(boolean|object)} [input.mouse=true] - [description] - * @property {*} [input.mouse.target=null] - [description] - * @property {boolean} [input.touch=true] - [description] - * @property {integer} [input.activePointers=1] - [description] - * @property {*} [input.touch.target=null] - [description] - * @property {boolean} [input.touch.capture=true] - [description] - * @property {(boolean|object)} [input.gamepad=false] - [description] + * @property {(boolean|InputConfig)} [input] - [description] * @property {boolean} [disableContextMenu=false] - [description] - * @property {(boolean|object)} [banner=false] - [description] - * @property {boolean} [banner.hidePhaser=false] - [description] - * @property {string} [banner.text='#ffffff'] - [description] - * @property {string[]} [banner.background] - [description] + * @property {(boolean|BannerConfig)} [banner=false] - [description] * @property {DOMContainerConfig} [dom] - The DOM Container configuration object. * @property {FPSConfig} [fps] - [description] - * @property {boolean} [render.antialias=true] - [description] - * @property {boolean} [render.pixelArt=false] - [description] - * @property {boolean} [render.autoResize=false] - [description] - * @property {boolean} [render.roundPixels=false] - [description] - * @property {boolean} [render.transparent=false] - [description] - * @property {boolean} [render.clearBeforeRender=true] - [description] - * @property {boolean} [render.premultipliedAlpha=true] - [description] - * @property {boolean} [render.preserveDrawingBuffer=false] - [description] - * @property {boolean} [render.failIfMajorPerformanceCaveat=false] - [description] - * @property {string} [render.powerPreference='default'] - "high-performance", "low-power" or "default" - * @property {integer} [render.batchSize=2000] - The default WebGL batch size. + * @property {RenderConfig} [render] - [description] * @property {(string|number)} [backgroundColor=0x000000] - [description] - * @property {object} [callbacks] - [description] - * @property {BootCallback} [callbacks.preBoot=NOOP] - [description] - * @property {BootCallback} [callbacks.postBoot=NOOP] - [description] + * @property {CallbacksConfig} [callbacks] - [description] * @property {LoaderConfig} [loader] - [description] - * @property {object} [images] - [description] - * @property {string} [images.default] - [description] - * @property {string} [images.missing] - [description] + * @property {ImagesConfig} [images] - [description] * @property {object} [physics] - [description] * @property {PluginObject|PluginObjectItem[]} [plugins] - [description] */ @@ -619,7 +667,7 @@ var Config = new Class({ * @const {string} Phaser.Boot.Config#defaultImage - [description] */ this.defaultImage = GetValue(config, 'images.default', pngPrefix + 'AQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg=='); - + /** * @const {string} Phaser.Boot.Config#missingImage - [description] */ From b14d9205815edf184b9a37486468592eb80de30c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20DUSSAUGE?= Date: Mon, 13 Aug 2018 21:59:58 +0200 Subject: [PATCH 5/7] Replace DistanceBetween with DistanceSquared in closest() and furthest() functions (ArcadePhysics.js) --- src/physics/arcade/ArcadePhysics.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/physics/arcade/ArcadePhysics.js b/src/physics/arcade/ArcadePhysics.js index f05d3fcec..9b0d9ba42 100644 --- a/src/physics/arcade/ArcadePhysics.js +++ b/src/physics/arcade/ArcadePhysics.js @@ -7,6 +7,7 @@ var Class = require('../../utils/Class'); var DegToRad = require('../../math/DegToRad'); var DistanceBetween = require('../../math/distance/DistanceBetween'); +var DistanceSquared = require('../../math/distance/DistanceSquared'); var Factory = require('./Factory'); var GetFastValue = require('../../utils/object/GetFastValue'); var Merge = require('../../utils/object/Merge'); @@ -310,7 +311,7 @@ var ArcadePhysics = new Class({ for (var i = bodies.length - 1; i >= 0; i--) { var target = bodies[i]; - var distance = DistanceBetween(x, y, target.x, target.y); + var distance = DistanceSquared(x, y, target.x, target.y); if (distance < min) { @@ -344,7 +345,7 @@ var ArcadePhysics = new Class({ for (var i = bodies.length - 1; i >= 0; i--) { var target = bodies[i]; - var distance = DistanceBetween(x, y, target.x, target.y); + var distance = DistanceSquared(x, y, target.x, target.y); if (distance > max) { From 7992924aaeabfb5a5933b25f9c009f2fa1c549fe Mon Sep 17 00:00:00 2001 From: TadejZupancic Date: Tue, 14 Aug 2018 12:15:59 +0200 Subject: [PATCH 6/7] Wrong bounds/displayTextOrigin on BitmapText text change updateDisplayOrigin needs current width and height, which are not recalculated if the _dirty is not set to true. --- src/gameobjects/bitmaptext/static/BitmapText.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gameobjects/bitmaptext/static/BitmapText.js b/src/gameobjects/bitmaptext/static/BitmapText.js index 41afc8e5c..1b45a788c 100644 --- a/src/gameobjects/bitmaptext/static/BitmapText.js +++ b/src/gameobjects/bitmaptext/static/BitmapText.js @@ -340,9 +340,9 @@ var BitmapText = new Class({ { this._text = value.toString(); - this.updateDisplayOrigin(); - this._dirty = true; + + this.updateDisplayOrigin(); } return this; From 1ac7c969ea0067e30fe1ba72c0153452fb765b63 Mon Sep 17 00:00:00 2001 From: James Simpson Date: Fri, 17 Aug 2018 14:03:17 -0500 Subject: [PATCH 7/7] Don't set gl.clearColor when no clearBeforeRender Unless I'm missing something, the `gl.clearColor` command is unnecessary when you have `this.config.clearBeforeRender` set to `false`. This simply moves that into the config check to eliminate an unused command in those situations. --- src/renderer/webgl/WebGLRenderer.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/renderer/webgl/WebGLRenderer.js b/src/renderer/webgl/WebGLRenderer.js index c428dc735..6a5b5400c 100644 --- a/src/renderer/webgl/WebGLRenderer.js +++ b/src/renderer/webgl/WebGLRenderer.js @@ -1636,11 +1636,9 @@ var WebGLRenderer = new Class({ var color = this.config.backgroundColor; var pipelines = this.pipelines; - // Bind custom framebuffer here - gl.clearColor(color.redGL, color.greenGL, color.blueGL, color.alphaGL); - if (this.config.clearBeforeRender) { + gl.clearColor(color.redGL, color.greenGL, color.blueGL, color.alphaGL); gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT); }