mirror of
https://github.com/photonstorm/phaser
synced 2024-12-01 00:49:41 +00:00
Documented the Text game object and its TextStyle companion.
Minor update to JSON representation descriptions.
This commit is contained in:
parent
28851ff69b
commit
a6b8b8ed31
5 changed files with 215 additions and 158 deletions
|
@ -397,7 +397,7 @@ var DynamicBitmapText = new Class({
|
|||
* @method Phaser.GameObjects.DynamicBitmapText#toJSON
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {JSONBitmapText} The JSON representation of this Bitmap Text.
|
||||
* @return {JSONBitmapText} A JSON representation of this Bitmap Text.
|
||||
*/
|
||||
toJSON: function ()
|
||||
{
|
||||
|
|
|
@ -320,7 +320,7 @@ var BitmapText = new Class({
|
|||
* @method Phaser.GameObjects.BitmapText#toJSON
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {JSONBitmapText} The JSON representation of this Bitmap Text.
|
||||
* @return {JSONBitmapText} A JSON representation of this Bitmap Text.
|
||||
*/
|
||||
toJSON: function ()
|
||||
{
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
*
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to export as JSON.
|
||||
*
|
||||
* @return {JSONGameObject} The JSON representation of the Game Object.
|
||||
* @return {JSONGameObject} A JSON representation of the Game Object.
|
||||
*/
|
||||
var ToJSON = function (gameObject)
|
||||
{
|
||||
|
|
|
@ -52,7 +52,7 @@ var propertyMap = {
|
|||
|
||||
/**
|
||||
* @classdesc
|
||||
* [description]
|
||||
* Style settings for a Text object.
|
||||
*
|
||||
* @class TextStyle
|
||||
* @memberOf Phaser.GameObjects.Text
|
||||
|
@ -60,7 +60,7 @@ var propertyMap = {
|
|||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.Text} text - The Text object that this TextStyle is styling.
|
||||
* @param {object} style - [description]
|
||||
* @param {CSSStyleRule} style - The style settings to set.
|
||||
*/
|
||||
var TextStyle = new Class({
|
||||
|
||||
|
@ -78,7 +78,7 @@ var TextStyle = new Class({
|
|||
this.parent = text;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The font family.
|
||||
*
|
||||
* @name Phaser.GameObjects.Text.TextStyle#fontFamily
|
||||
* @type {string}
|
||||
|
@ -88,7 +88,7 @@ var TextStyle = new Class({
|
|||
this.fontFamily;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The font size.
|
||||
*
|
||||
* @name Phaser.GameObjects.Text.TextStyle#fontSize
|
||||
* @type {string}
|
||||
|
@ -98,7 +98,7 @@ var TextStyle = new Class({
|
|||
this.fontSize;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The font style.
|
||||
*
|
||||
* @name Phaser.GameObjects.Text.TextStyle#fontStyle
|
||||
* @type {string}
|
||||
|
@ -107,7 +107,7 @@ var TextStyle = new Class({
|
|||
this.fontStyle;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The background color.
|
||||
*
|
||||
* @name Phaser.GameObjects.Text.TextStyle#backgroundColor
|
||||
* @type {string}
|
||||
|
@ -116,7 +116,7 @@ var TextStyle = new Class({
|
|||
this.backgroundColor;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The text fill color.
|
||||
*
|
||||
* @name Phaser.GameObjects.Text.TextStyle#color
|
||||
* @type {string}
|
||||
|
@ -126,7 +126,7 @@ var TextStyle = new Class({
|
|||
this.color;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The text stroke color.
|
||||
*
|
||||
* @name Phaser.GameObjects.Text.TextStyle#stroke
|
||||
* @type {string}
|
||||
|
@ -136,7 +136,7 @@ var TextStyle = new Class({
|
|||
this.stroke;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The text stroke thickness.
|
||||
*
|
||||
* @name Phaser.GameObjects.Text.TextStyle#strokeThickness
|
||||
* @type {number}
|
||||
|
@ -146,7 +146,7 @@ var TextStyle = new Class({
|
|||
this.strokeThickness;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The horizontal shadow offset.
|
||||
*
|
||||
* @name Phaser.GameObjects.Text.TextStyle#shadowOffsetX
|
||||
* @type {number}
|
||||
|
@ -156,7 +156,7 @@ var TextStyle = new Class({
|
|||
this.shadowOffsetX;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The vertical shadow offset.
|
||||
*
|
||||
* @name Phaser.GameObjects.Text.TextStyle#shadowOffsetY
|
||||
* @type {number}
|
||||
|
@ -166,7 +166,7 @@ var TextStyle = new Class({
|
|||
this.shadowOffsetY;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The shadow color.
|
||||
*
|
||||
* @name Phaser.GameObjects.Text.TextStyle#shadowColor
|
||||
* @type {string}
|
||||
|
@ -176,7 +176,7 @@ var TextStyle = new Class({
|
|||
this.shadowColor;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The shadow blur radius.
|
||||
*
|
||||
* @name Phaser.GameObjects.Text.TextStyle#shadowBlur
|
||||
* @type {number}
|
||||
|
@ -186,7 +186,7 @@ var TextStyle = new Class({
|
|||
this.shadowBlur;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Whether shadow stroke is enabled or not.
|
||||
*
|
||||
* @name Phaser.GameObjects.Text.TextStyle#shadowStroke
|
||||
* @type {boolean}
|
||||
|
@ -196,7 +196,7 @@ var TextStyle = new Class({
|
|||
this.shadowStroke;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Whether shadow fill is enabled or not.
|
||||
*
|
||||
* @name Phaser.GameObjects.Text.TextStyle#shadowFill
|
||||
* @type {boolean}
|
||||
|
@ -206,7 +206,7 @@ var TextStyle = new Class({
|
|||
this.shadowFill;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The text alignment.
|
||||
*
|
||||
* @name Phaser.GameObjects.Text.TextStyle#align
|
||||
* @type {string}
|
||||
|
@ -216,7 +216,7 @@ var TextStyle = new Class({
|
|||
this.align;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The maximum number of lines to draw.
|
||||
*
|
||||
* @name Phaser.GameObjects.Text.TextStyle#maxLines
|
||||
* @type {integer}
|
||||
|
@ -226,7 +226,9 @@ var TextStyle = new Class({
|
|||
this.maxLines;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The fixed width of the text.
|
||||
*
|
||||
* `0` means no fixed with.
|
||||
*
|
||||
* @name Phaser.GameObjects.Text.TextStyle#fixedWidth
|
||||
* @type {number}
|
||||
|
@ -236,7 +238,9 @@ var TextStyle = new Class({
|
|||
this.fixedWidth;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The fixed height of the text.
|
||||
*
|
||||
* `0` means no fixed height.
|
||||
*
|
||||
* @name Phaser.GameObjects.Text.TextStyle#fixedHeight
|
||||
* @type {number}
|
||||
|
@ -246,7 +250,7 @@ var TextStyle = new Class({
|
|||
this.fixedHeight;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Whether the text should render right to left.
|
||||
*
|
||||
* @name Phaser.GameObjects.Text.TextStyle#rtl
|
||||
* @type {boolean}
|
||||
|
@ -256,7 +260,7 @@ var TextStyle = new Class({
|
|||
this.rtl;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The test string to use when measuring the font.
|
||||
*
|
||||
* @name Phaser.GameObjects.Text.TextStyle#testString
|
||||
* @type {string}
|
||||
|
@ -286,7 +290,7 @@ var TextStyle = new Class({
|
|||
this.baselineY;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The font style, size and family.
|
||||
*
|
||||
* @name Phaser.GameObjects.Text.TextStyle#_font
|
||||
* @type {string}
|
||||
|
@ -317,13 +321,25 @@ var TextStyle = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Set the text style.
|
||||
*
|
||||
* For example:
|
||||
*
|
||||
* ```javascript
|
||||
* text.style.setStyle({
|
||||
* fontSize: '64px',
|
||||
* fontFamily: 'Arial',
|
||||
* color: '#ffffff',
|
||||
* align: 'center',
|
||||
* backgroundColor: '#ff00ff'
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* @method Phaser.GameObjects.Text.TextStyle#setStyle
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {CSSStyleRule} style - [description]
|
||||
* @param {boolean} [updateText=true] - [description]
|
||||
* @param {object} style - The style settings to set.
|
||||
* @param {boolean} [updateText=true] - Whether to update the text immediately.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Text} The parent Text object.
|
||||
*/
|
||||
|
@ -381,13 +397,13 @@ var TextStyle = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Synchronize the font settings to the given Canvas Rendering Context.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text.TextStyle#syncFont
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {HTMLCanvasElement} canvas - [description]
|
||||
* @param {CanvasRenderingContext2D} context - [description]
|
||||
* @param {HTMLCanvasElement} canvas - The Canvas Element.
|
||||
* @param {CanvasRenderingContext2D} context - The Canvas Rendering Context.
|
||||
*/
|
||||
syncFont: function (canvas, context)
|
||||
{
|
||||
|
@ -395,13 +411,13 @@ var TextStyle = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Synchronize the text style settings to the given Canvas Rendering Context.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text.TextStyle#syncStyle
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {HTMLCanvasElement} canvas - [description]
|
||||
* @param {CanvasRenderingContext2D} context - [description]
|
||||
* @param {HTMLCanvasElement} canvas - The Canvas Element.
|
||||
* @param {CanvasRenderingContext2D} context - The Canvas Rendering Context.
|
||||
*/
|
||||
syncStyle: function (canvas, context)
|
||||
{
|
||||
|
@ -416,13 +432,13 @@ var TextStyle = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Synchronize the shadow settings to the given Canvas Rendering Context.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text.TextStyle#syncShadow
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {CanvasRenderingContext2D} context - [description]
|
||||
* @param {boolean} enabled - [description]
|
||||
* @param {CanvasRenderingContext2D} context - The Canvas Rendering Context.
|
||||
* @param {boolean} enabled - Whether shadows are enabled or not.
|
||||
*/
|
||||
syncShadow: function (context, enabled)
|
||||
{
|
||||
|
@ -443,12 +459,12 @@ var TextStyle = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Update the style settings for the parent Text object.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text.TextStyle#update
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {boolean} recalculateMetrics - [description]
|
||||
* @param {boolean} recalculateMetrics - Whether to recalculate font and text metrics.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Text} The parent Text object.
|
||||
*/
|
||||
|
@ -465,12 +481,17 @@ var TextStyle = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Set the font.
|
||||
*
|
||||
* If a string is given, the font family is set.
|
||||
*
|
||||
* If an object is given, the `fontFamily`, `fontSize` and `fontStyle`
|
||||
* properties of that object are set.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text.TextStyle#setFont
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {(string|object)} font - [description]
|
||||
* @param {(string|object)} font - The font family or font settings to set.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Text} The parent Text object.
|
||||
*/
|
||||
|
@ -493,12 +514,12 @@ var TextStyle = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Set the font family.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text.TextStyle#setFontFamily
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} family - [description]
|
||||
* @param {string} family - The font family.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Text} The parent Text object.
|
||||
*/
|
||||
|
@ -510,12 +531,12 @@ var TextStyle = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Set the font style.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text.TextStyle#setFontStyle
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} style - [description]
|
||||
* @param {string} style - The font style.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Text} The parent Text object.
|
||||
*/
|
||||
|
@ -527,12 +548,12 @@ var TextStyle = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Set the font size.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text.TextStyle#setFontSize
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {(number|string)} size - [description]
|
||||
* @param {(number|string)} size - The font size.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Text} The parent Text object.
|
||||
*/
|
||||
|
@ -549,12 +570,12 @@ var TextStyle = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Set the test string to use when measuring the font.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text.TextStyle#setTestString
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} string - [description]
|
||||
* @param {string} string - The test string to use when measuring the font.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Text} The parent Text object.
|
||||
*/
|
||||
|
@ -566,13 +587,15 @@ var TextStyle = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Set a fixed width and height for the text.
|
||||
*
|
||||
* Pass in `0` for either of these parameters to disable fixed width or height respectively.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text.TextStyle#setFixedSize
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} width - [description]
|
||||
* @param {number} height - [description]
|
||||
* @param {number} width - The fixed width to set.
|
||||
* @param {number} height - The fixed height to set.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Text} The parent Text object.
|
||||
*/
|
||||
|
@ -595,12 +618,12 @@ var TextStyle = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Set the background color.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text.TextStyle#setBackgroundColor
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} color - [description]
|
||||
* @param {string} color - The background color.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Text} The parent Text object.
|
||||
*/
|
||||
|
@ -612,12 +635,12 @@ var TextStyle = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Set the text fill color.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text.TextStyle#setFill
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} color - [description]
|
||||
* @param {string} color - The text fill color.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Text} The parent Text object.
|
||||
*/
|
||||
|
@ -629,12 +652,12 @@ var TextStyle = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Set the text fill color.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text.TextStyle#setColor
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} color - [description]
|
||||
* @param {string} color - The text fill color.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Text} The parent Text object.
|
||||
*/
|
||||
|
@ -646,13 +669,13 @@ var TextStyle = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Set the stroke settings.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text.TextStyle#setStroke
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} color - [description]
|
||||
* @param {number} thickness - [description]
|
||||
* @param {string} color - The stroke color.
|
||||
* @param {number} thickness - The stroke thickness.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Text} The parent Text object.
|
||||
*/
|
||||
|
@ -675,17 +698,17 @@ var TextStyle = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Set the shadow settings.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text.TextStyle#setShadow
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} [x=0] - [description]
|
||||
* @param {number} [y=0] - [description]
|
||||
* @param {string} [color='#000'] - [description]
|
||||
* @param {number} [blur=0] - [description]
|
||||
* @param {boolean} [shadowStroke=false] - [description]
|
||||
* @param {boolean} [shadowFill=true] - [description]
|
||||
* @param {number} [x=0] - The horizontal shadow offset.
|
||||
* @param {number} [y=0] - The vertical shadow offset.
|
||||
* @param {string} [color='#000'] - The shadow color.
|
||||
* @param {number} [blur=0] - The shadow blur radius.
|
||||
* @param {boolean} [shadowStroke=false] - Whether to stroke the shadow.
|
||||
* @param {boolean} [shadowFill=true] - Whether to fill the shadow.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Text} The parent Text object.
|
||||
*/
|
||||
|
@ -709,13 +732,13 @@ var TextStyle = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Set the shadow offset.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text.TextStyle#setShadowOffset
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} [x=0] - [description]
|
||||
* @param {number} [y=0] - [description]
|
||||
* @param {number} [x=0] - The horizontal shadow offset.
|
||||
* @param {number} [y=0] - The vertical shadow offset.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Text} The parent Text object.
|
||||
*/
|
||||
|
@ -731,12 +754,12 @@ var TextStyle = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Set the shadow color.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text.TextStyle#setShadowColor
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} [color='#000'] - [description]
|
||||
* @param {string} [color='#000'] - The shadow color.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Text} The parent Text object.
|
||||
*/
|
||||
|
@ -750,12 +773,12 @@ var TextStyle = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Set the shadow blur radius.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text.TextStyle#setShadowBlur
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} [blur=0] - [description]
|
||||
* @param {number} [blur=0] - The shadow blur radius.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Text} The parent Text object.
|
||||
*/
|
||||
|
@ -769,12 +792,12 @@ var TextStyle = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Enable or disable shadow stroke.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text.TextStyle#setShadowStroke
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {boolean} enabled - [description]
|
||||
* @param {boolean} enabled - Whether shadow stroke is enabled or not.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Text} The parent Text object.
|
||||
*/
|
||||
|
@ -786,12 +809,12 @@ var TextStyle = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Enable or disable shadow fill.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text.TextStyle#setShadowFill
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {boolean} enabled - [description]
|
||||
* @param {boolean} enabled - Whether shadow fill is enabled or not.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Text} The parent Text object.
|
||||
*/
|
||||
|
@ -803,7 +826,9 @@ var TextStyle = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* Set the width (in pixels) to use for wrapping lines. Pass in null to remove wrapping by width.
|
||||
* Set the width (in pixels) to use for wrapping lines.
|
||||
*
|
||||
* Pass in null to remove wrapping by width.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text.TextStyle#setWordWrapWidth
|
||||
* @since 3.0.0
|
||||
|
@ -826,7 +851,9 @@ var TextStyle = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* Set a custom callback for wrapping lines. Pass in null to remove wrapping by callback.
|
||||
* Set a custom callback for wrapping lines.
|
||||
*
|
||||
* Pass in null to remove wrapping by callback.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text.TextStyle#setWordWrapCallback
|
||||
* @since 3.0.0
|
||||
|
@ -850,12 +877,14 @@ var TextStyle = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Set the text alignment.
|
||||
*
|
||||
* Expects values like `'left'`, `'right'`, `'center'` or `'justified'`.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text.TextStyle#setAlign
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} align - [description]
|
||||
* @param {string} align - The text alignment.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Text} The parent Text object.
|
||||
*/
|
||||
|
@ -869,12 +898,12 @@ var TextStyle = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Set the maximum number of lines to draw.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text.TextStyle#setMaxLines
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {integer} [max=0] - [description]
|
||||
* @param {integer} [max=0] - The maximum number of lines to draw.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Text} The parent Text object.
|
||||
*/
|
||||
|
@ -888,12 +917,12 @@ var TextStyle = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Get the current text metrics.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text.TextStyle#getTextMetrics
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {object} [description]
|
||||
* @return {object} The text metrics.
|
||||
*/
|
||||
getTextMetrics: function ()
|
||||
{
|
||||
|
@ -907,12 +936,12 @@ var TextStyle = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Build a JSON representation of this Text Style.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text.TextStyle#toJSON
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {object} [description]
|
||||
* @return {object} A JSON representation of this Text Style.
|
||||
*/
|
||||
toJSON: function ()
|
||||
{
|
||||
|
@ -929,7 +958,7 @@ var TextStyle = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Destroy this Text Style.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text.TextStyle#destroy
|
||||
* @since 3.0.0
|
||||
|
|
|
@ -101,7 +101,9 @@ var Text = new Class({
|
|||
this.context = this.canvas.getContext('2d');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The Text Style object.
|
||||
*
|
||||
* Manages the style of this Text object.
|
||||
*
|
||||
* @name Phaser.GameObjects.Text#style
|
||||
* @type {Phaser.GameObjects.Text.TextStyle}
|
||||
|
@ -110,7 +112,7 @@ var Text = new Class({
|
|||
this.style = new TextStyle(this, style);
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Whether to automatically round line positions.
|
||||
*
|
||||
* @name Phaser.GameObjects.Text#autoRound
|
||||
* @type {boolean}
|
||||
|
@ -131,7 +133,7 @@ var Text = new Class({
|
|||
this.splitRegExp = /(?:\r\n|\r|\n)/;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The text to display.
|
||||
*
|
||||
* @name Phaser.GameObjects.Text#text
|
||||
* @type {string}
|
||||
|
@ -140,7 +142,7 @@ var Text = new Class({
|
|||
this.text = '';
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The resolution of the text.
|
||||
*
|
||||
* @name Phaser.GameObjects.Text#resolution
|
||||
* @type {number}
|
||||
|
@ -160,7 +162,7 @@ var Text = new Class({
|
|||
this.padding = { left: 0, right: 0, top: 0, bottom: 0 };
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The width of this Text object.
|
||||
*
|
||||
* @name Phaser.GameObjects.Text#width
|
||||
* @type {number}
|
||||
|
@ -170,7 +172,7 @@ var Text = new Class({
|
|||
this.width = 1;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The height of this Text object.
|
||||
*
|
||||
* @name Phaser.GameObjects.Text#height
|
||||
* @type {number}
|
||||
|
@ -180,7 +182,7 @@ var Text = new Class({
|
|||
this.height = 1;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The Canvas Texture that the text is rendered to for WebGL rendering.
|
||||
*
|
||||
* @name Phaser.GameObjects.Text#canvasTexture
|
||||
* @type {HTMLCanvasElement}
|
||||
|
@ -190,7 +192,7 @@ var Text = new Class({
|
|||
this.canvasTexture = null;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Whether the text or its settings have changed and need updating.
|
||||
*
|
||||
* @name Phaser.GameObjects.Text#dirty
|
||||
* @type {boolean}
|
||||
|
@ -224,7 +226,7 @@ var Text = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Initialize right to left text.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text#initRTL
|
||||
* @since 3.0.0
|
||||
|
@ -308,8 +310,8 @@ var Text = new Class({
|
|||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} text - The text to perform word wrap detection against.
|
||||
* @param {CanvasRenderingContext2D} context - [description]
|
||||
* @param {number} wordWrapWidth - [description]
|
||||
* @param {CanvasRenderingContext2D} context - The Canvas Rendering Context.
|
||||
* @param {number} wordWrapWidth - The word wrap width.
|
||||
*
|
||||
* @return {string} The wrapped text.
|
||||
*/
|
||||
|
@ -428,8 +430,8 @@ var Text = new Class({
|
|||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} text - The text to perform word wrap detection against.
|
||||
* @param {CanvasRenderingContext2D} context - [description]
|
||||
* @param {number} wordWrapWidth - [description]
|
||||
* @param {CanvasRenderingContext2D} context - The Canvas Rendering Context.
|
||||
* @param {number} wordWrapWidth - The word wrap width.
|
||||
*
|
||||
* @return {string} The wrapped text.
|
||||
*/
|
||||
|
@ -504,7 +506,9 @@ var Text = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Set the text to display.
|
||||
*
|
||||
* An array of strings will be joined with `\n` line breaks.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text#setText
|
||||
* @since 3.0.0
|
||||
|
@ -536,12 +540,24 @@ var Text = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Set the text style.
|
||||
*
|
||||
* For example:
|
||||
*
|
||||
* ```javascript
|
||||
* text.setStyle({
|
||||
* fontSize: '64px',
|
||||
* fontFamily: 'Arial',
|
||||
* color: '#ffffff',
|
||||
* align: 'center',
|
||||
* backgroundColor: '#ff00ff'
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* @method Phaser.GameObjects.Text#setStyle
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {object} style - [description]
|
||||
* @param {object} style - The style settings to set.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Text} This Text object.
|
||||
*/
|
||||
|
@ -551,12 +567,17 @@ var Text = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Set the font.
|
||||
*
|
||||
* If a string is given, the font family is set.
|
||||
*
|
||||
* If an object is given, the `fontFamily`, `fontSize` and `fontStyle`
|
||||
* properties of that object are set.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text#setFont
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} font - [description]
|
||||
* @param {string} font - The font family or font settings to set.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Text} This Text object.
|
||||
*/
|
||||
|
@ -566,12 +587,12 @@ var Text = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Set the font family.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text#setFontFamily
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} family - [description]
|
||||
* @param {string} family - The font family.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Text} This Text object.
|
||||
*/
|
||||
|
@ -581,12 +602,12 @@ var Text = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Set the font size.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text#setFontSize
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} size - [description]
|
||||
* @param {number} size - The font size.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Text} This Text object.
|
||||
*/
|
||||
|
@ -596,12 +617,12 @@ var Text = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Set the font style.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text#setFontStyle
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} style - [description]
|
||||
* @param {string} style - The font style.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Text} This Text object.
|
||||
*/
|
||||
|
@ -611,13 +632,15 @@ var Text = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Set a fixed width and height for the text.
|
||||
*
|
||||
* Pass in `0` for either of these parameters to disable fixed width or height respectively.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text#setFixedSize
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} width - [description]
|
||||
* @param {number} height - [description]
|
||||
* @param {number} width - The fixed width to set. `0` disables fixed width.
|
||||
* @param {number} height - The fixed height to set. `0` disables fixed height.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Text} This Text object.
|
||||
*/
|
||||
|
@ -627,12 +650,12 @@ var Text = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Set the background color.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text#setBackgroundColor
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} color - [description]
|
||||
* @param {string} color - The background color.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Text} This Text object.
|
||||
*/
|
||||
|
@ -642,12 +665,12 @@ var Text = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Set the text fill color.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text#setFill
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} color - [description]
|
||||
* @param {string} color - The text fill color.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Text} This Text object.
|
||||
*/
|
||||
|
@ -657,12 +680,12 @@ var Text = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Set the text fill color.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text#setColor
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} color - [description]
|
||||
* @param {string} color - The text fill color.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Text} This Text object.
|
||||
*/
|
||||
|
@ -672,13 +695,13 @@ var Text = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Set the stroke settings.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text#setStroke
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} color - [description]
|
||||
* @param {number} thickness - [description]
|
||||
* @param {string} color - The stroke color.
|
||||
* @param {number} thickness - The stroke thickness.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Text} This Text object.
|
||||
*/
|
||||
|
@ -688,17 +711,17 @@ var Text = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Set the shadow settings.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text#setShadow
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} x - [description]
|
||||
* @param {number} y - [description]
|
||||
* @param {string} color - [description]
|
||||
* @param {number} blur - [description]
|
||||
* @param {boolean} shadowStroke - [description]
|
||||
* @param {boolean} shadowFill - [description]
|
||||
* @param {number} [x=0] - The horizontal shadow offset.
|
||||
* @param {number} [y=0] - The vertical shadow offset.
|
||||
* @param {string} [color='#000'] - The shadow color.
|
||||
* @param {number} [blur=0] - The shadow blur radius.
|
||||
* @param {boolean} [shadowStroke=false] - Whether to stroke the shadow.
|
||||
* @param {boolean} [shadowFill=true] - Whether to fill the shadow.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Text} This Text object.
|
||||
*/
|
||||
|
@ -708,13 +731,13 @@ var Text = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Set the shadow offset.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text#setShadowOffset
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} x - [description]
|
||||
* @param {number} y - [description]
|
||||
* @param {number} x - The horizontal shadow offset.
|
||||
* @param {number} y - The vertical shadow offset.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Text} This Text object.
|
||||
*/
|
||||
|
@ -724,12 +747,12 @@ var Text = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Set the shadow color.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text#setShadowColor
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} color - [description]
|
||||
* @param {string} color - The shadow color.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Text} This Text object.
|
||||
*/
|
||||
|
@ -739,12 +762,12 @@ var Text = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Set the shadow blur radius.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text#setShadowBlur
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} blur - [description]
|
||||
* @param {number} blur - The shadow blur radius.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Text} This Text object.
|
||||
*/
|
||||
|
@ -754,12 +777,12 @@ var Text = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Enable or disable shadow stroke.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text#setShadowStroke
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {boolean} enabled - [description]
|
||||
* @param {boolean} enabled - Whether shadow stroke is enabled or not.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Text} This Text object.
|
||||
*/
|
||||
|
@ -769,12 +792,12 @@ var Text = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Enable or disable shadow fill.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text#setShadowFill
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {boolean} enabled - [description]
|
||||
* @param {boolean} enabled - Whether shadow fill is enabled or not.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Text} This Text object.
|
||||
*/
|
||||
|
@ -821,12 +844,14 @@ var Text = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Set the text alignment.
|
||||
*
|
||||
* Expects values like `'left'`, `'right'`, `'center'` or `'justified'`.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text#setAlign
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} align - [description]
|
||||
* @param {string} align - The text alignment.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Text} This Text object.
|
||||
*/
|
||||
|
@ -836,16 +861,19 @@ var Text = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* Set the text padding.
|
||||
*
|
||||
* 'left' can be an object.
|
||||
* If only 'left' and 'top' are given they are treated as 'x' and 'y'
|
||||
*
|
||||
* If only 'left' and 'top' are given they are treated as 'x' and 'y'.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text#setPadding
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {(number|object)} left - [description]
|
||||
* @param {number} top - [description]
|
||||
* @param {number} right - [description]
|
||||
* @param {number} bottom - [description]
|
||||
* @param {(number|object)} left - The left padding value, or a padding config object.
|
||||
* @param {number} top - The top padding value.
|
||||
* @param {number} right - The right padding value.
|
||||
* @param {number} bottom - The bottom padding value.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Text} This Text object.
|
||||
*/
|
||||
|
@ -899,12 +927,12 @@ var Text = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Set the maximum number of lines to draw.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text#setMaxLines
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {integer} [max=0] - [description]
|
||||
* @param {integer} [max=0] - The maximum number of lines to draw.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Text} This Text object.
|
||||
*/
|
||||
|
@ -914,7 +942,7 @@ var Text = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Update the displayed text.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text#updateText
|
||||
* @since 3.0.0
|
||||
|
@ -1050,12 +1078,12 @@ var Text = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Get the current text metrics.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text#getTextMetrics
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {object} [description]
|
||||
* @return {object} The text metrics.
|
||||
*/
|
||||
getTextMetrics: function ()
|
||||
{
|
||||
|
@ -1063,12 +1091,12 @@ var Text = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Build a JSON representation of the Text object.
|
||||
*
|
||||
* @method Phaser.GameObjects.Text#toJSON
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {JSONGameObject} A JSON representation of the Game Object.
|
||||
* @return {JSONGameObject} A JSON representation of the Text object.
|
||||
*/
|
||||
toJSON: function ()
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue