Documented DynamicBitmapText display callbacks.

Finished up some DynamicBitmapText related descriptions.

Removed the align property from BitmapTextConfig, as it's not used.
This commit is contained in:
Chris Andrew 2018-06-06 17:26:55 +01:00
parent 79c3242c68
commit fb33fd045d
5 changed files with 28 additions and 22 deletions

View file

@ -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)
{

View file

@ -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.
*/

View file

@ -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)
{

View file

@ -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.
*/

View file

@ -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.
*/