From fb33fd045d562e1da187a2f0afd69a06357f4888 Mon Sep 17 00:00:00 2001 From: Chris Andrew Date: Wed, 6 Jun 2018 17:26:55 +0100 Subject: [PATCH] Documented DynamicBitmapText display callbacks. Finished up some DynamicBitmapText related descriptions. Removed the align property from BitmapTextConfig, as it's not used. --- src/gameobjects/bitmaptext/ParseRetroFont.js | 2 +- .../bitmaptext/dynamic/DynamicBitmapText.js | 32 ++++++++++++------- .../dynamic/DynamicBitmapTextCreator.js | 4 +-- .../dynamic/DynamicBitmapTextFactory.js | 6 ++-- .../bitmaptext/static/BitmapTextFactory.js | 6 ++-- 5 files changed, 28 insertions(+), 22 deletions(-) diff --git a/src/gameobjects/bitmaptext/ParseRetroFont.js b/src/gameobjects/bitmaptext/ParseRetroFont.js index 84e612bc9..a72b597a4 100644 --- a/src/gameobjects/bitmaptext/ParseRetroFont.js +++ b/src/gameobjects/bitmaptext/ParseRetroFont.js @@ -16,7 +16,7 @@ var GetValue = require('../../utils/object/GetValue'); * @param {Phaser.Scene} scene - A reference to the Phaser Scene. * @param {Phaser.GameObjects.RetroFont.Config} config - The font configuration object. * - * @return {object} [description] + * @return {object} A parsed Bitmap Font data entry for the Bitmap Font cache. */ var ParseRetroFont = function (scene, config) { diff --git a/src/gameobjects/bitmaptext/dynamic/DynamicBitmapText.js b/src/gameobjects/bitmaptext/dynamic/DynamicBitmapText.js index 9a388bc5b..5d8c8f7bf 100644 --- a/src/gameobjects/bitmaptext/dynamic/DynamicBitmapText.js +++ b/src/gameobjects/bitmaptext/dynamic/DynamicBitmapText.js @@ -12,20 +12,22 @@ var Render = require('./DynamicBitmapTextRender'); /** * @typedef {object} DisplayCallbackConfig - * @property {{topLeft:number,topRight:number,bottomLeft:number,bottomRight:number}} tint - [description] - * @property {number} index - [description] - * @property {number} charCode - [description] - * @property {number} x - [description] - * @property {number} y - [description] - * @property {number} scale - [description] - * @property {number} rotation - [description] - * @property {any} data - [description] + * @property {{topLeft:number,topRight:number,bottomLeft:number,bottomRight:number}} tint - The tint of the character being rendered. + * @property {number} index - The index of the character being rendered. + * @property {number} charCode - The character code of the character being rendered. + * @property {number} x - The x position of the character being rendered. + * @property {number} y - The y position of the character being rendered. + * @property {number} scale - The scale of the character being rendered. + * @property {number} rotation - The rotation of the character being rendered. + * @property {any} data - Custom data stored with the character being rendered. */ /** * @callback DisplayCallback * - * @param {DisplayCallbackConfig} display - [description] + * @param {DisplayCallbackConfig} display - Settings of the character that is about to be rendered. + * + * @return {{x:number, y:number, scale:number, rotation:number}} Altered position, scale and rotation values for the character that is about to be rendered. */ /** @@ -190,7 +192,7 @@ var DynamicBitmapText = new Class({ this.cropHeight = 0; /** - * [description] + * A callback that alters how each character of the Bitmap Text is rendered. * * @name Phaser.GameObjects.DynamicBitmapText#displayCallback; * @type {DisplayCallback} @@ -219,12 +221,18 @@ var DynamicBitmapText = new Class({ }, /** - * [description] + * Set a callback that alters how each character of the Bitmap Text is rendered. + * + * The callback receives a {@link DisplayCallbackConfig} object that contains information about the character that's + * about to be rendered. + * + * It should return an object with `x`, `y`, `scale` and `rotation` properties that will be used instead of the + * usual values when rendering. * * @method Phaser.GameObjects.DynamicBitmapText#setDisplayCallback * @since 3.0.0 * - * @param {DisplayCallback} callback - [description] + * @param {DisplayCallback} callback - The display callback to set. * * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. */ diff --git a/src/gameobjects/bitmaptext/dynamic/DynamicBitmapTextCreator.js b/src/gameobjects/bitmaptext/dynamic/DynamicBitmapTextCreator.js index 5674d3861..4179c3dba 100644 --- a/src/gameobjects/bitmaptext/dynamic/DynamicBitmapTextCreator.js +++ b/src/gameobjects/bitmaptext/dynamic/DynamicBitmapTextCreator.js @@ -16,7 +16,6 @@ var GetAdvancedValue = require('../../../utils/object/GetAdvancedValue'); * @property {string} [font=''] - The key of the font to use from the BitmapFont cache. * @property {string} [text=''] - The string, or array of strings, to be set as the content of this Bitmap Text. * @property {(number|false)} [size=false] - The font size to set. - * @property {string} [align='left'] - The alignment to set. */ /** @@ -39,9 +38,8 @@ GameObjectCreator.register('dynamicBitmapText', function (config, addToScene) var font = GetAdvancedValue(config, 'font', ''); var text = GetAdvancedValue(config, 'text', ''); var size = GetAdvancedValue(config, 'size', false); - var align = GetAdvancedValue(config, 'align', 'left'); - var bitmapText = new BitmapText(this.scene, 0, 0, font, text, size, align); + var bitmapText = new BitmapText(this.scene, 0, 0, font, text, size); if (addToScene !== undefined) { diff --git a/src/gameobjects/bitmaptext/dynamic/DynamicBitmapTextFactory.js b/src/gameobjects/bitmaptext/dynamic/DynamicBitmapTextFactory.js index df58733c4..ae478d6c7 100644 --- a/src/gameobjects/bitmaptext/dynamic/DynamicBitmapTextFactory.js +++ b/src/gameobjects/bitmaptext/dynamic/DynamicBitmapTextFactory.js @@ -17,9 +17,9 @@ var GameObjectFactory = require('../../GameObjectFactory'); * * @param {number} x - The x position of the Game Object. * @param {number} y - The y position of the Game Object. - * @param {string} font - [description] - * @param {(string|string[])} [text] - [description] - * @param {number} [size] - [description] + * @param {string} font - The key of the font to use from the BitmapFont cache. + * @param {(string|string[])} [text] - The string, or array of strings, to be set as the content of this Bitmap Text. + * @param {number} [size] - The font size to set. * * @return {Phaser.GameObjects.DynamicBitmapText} The Game Object that was created. */ diff --git a/src/gameobjects/bitmaptext/static/BitmapTextFactory.js b/src/gameobjects/bitmaptext/static/BitmapTextFactory.js index 4cdcd80eb..f722ec9cb 100644 --- a/src/gameobjects/bitmaptext/static/BitmapTextFactory.js +++ b/src/gameobjects/bitmaptext/static/BitmapTextFactory.js @@ -17,9 +17,9 @@ var GameObjectFactory = require('../../GameObjectFactory'); * * @param {number} x - The x position of the Game Object. * @param {number} y - The y position of the Game Object. - * @param {string} font - [description] - * @param {(string|string[])} [text] - [description] - * @param {number} [size] - [description] + * @param {string} font - The key of the font to use from the BitmapFont cache. + * @param {(string|string[])} [text] - The string, or array of strings, to be set as the content of this Bitmap Text. + * @param {number} [size] - The font size to set. * * @return {Phaser.GameObjects.BitmapText} The Game Object that was created. */