Class: Label
Extends
Implements
Constructors
new Label()
new Label(
options
):Label
Single or multi-line text formatted and rendered on the screen.
Parameters
• options: LabelOptions
= {}
Returns
Overrides
Remarks
Label (in contrast to TextLine) has enhanced text support for line wrapping, centering/alignment, and background colors.
Source
Properties
_alpha
_alpha:
number
=1.0
Inherited from
Source
_anchorPoint
private
_anchorPoint:Point
Source
_backgroundColor?
private
optional
_backgroundColor:RgbaColor
Source
_backgroundPaint?
private
optional
_backgroundPaint:Paint
Source
_draggable
protected
_draggable:boolean
=false
Inherited from
Source
_fontColor
private
_fontColor:RgbaColor
=Constants.DEFAULT_FONT_COLOR
Source
_fontName
private
_fontName:undefined
|string
Source
_fontNames
private
_fontNames:undefined
|string
[]
Source
_fontPaint?
private
optional
_fontPaint:Paint
Source
_fontSize
private
_fontSize:number
=Constants.DEFAULT_FONT_SIZE
Source
_game?
optional
_game:Game
Inherited from
Source
_hidden
protected
_hidden:boolean
=false
Inherited from
Source
_horizontalAlignmentMode
private
_horizontalAlignmentMode:LabelHorizontalAlignmentMode
=LabelHorizontalAlignmentMode.Center
Source
_interpolation
private
_interpolation:StringInterpolationMap
={}
Source
_isUserInteractionEnabled
protected
_isUserInteractionEnabled:boolean
=false
Inherited from
M2Node
._isUserInteractionEnabled
Source
_localize
private
_localize:boolean
=true
Source
_position
_position:
Point
Inherited from
Source
_preferredMaxLayoutWidth
private
_preferredMaxLayoutWidth:undefined
|number
Source
_scale
_scale:
number
=1.0
Inherited from
Source
_size
protected
_size:Size
Inherited from
Source
_text
private
_text:string
=""
Source
_zPosition
private
_zPosition:number
=0
Source
_zRotation
_zRotation:
number
=0
Inherited from
Source
absoluteAlpha
absoluteAlpha:
number
=1.0
Inherited from
Source
absoluteAlphaChange
absoluteAlphaChange:
number
=0
Inherited from
Source
absolutePosition
absolutePosition:
Point
Inherited from
Source
absoluteScale
absoluteScale:
number
=1.0
Inherited from
Source
actions
actions:
Action
[]
Inherited from
Source
builder?
private
optional
builder:ParagraphBuilder
Source
children
children:
M2Node
[]
Inherited from
Source
constructionIso8601TimeStamp
constructionIso8601TimeStamp:
string
Inherited from
M2Node
.constructionIso8601TimeStamp
Source
constructionSequence
constructionSequence:
number
Inherited from
Source
constructionTimeStamp
constructionTimeStamp:
number
Inherited from
Source
dragging
dragging:
boolean
=false
Is the node in a dragging state?
Inherited from
Source
draggingLastPointerOffset
draggingLastPointerOffset:
Point
What was the previous pointer offset when the node was in a dragging state?
Inherited from
M2Node
.draggingLastPointerOffset
Source
eventListeners
eventListeners:
M2NodeEventListener
<M2NodeEvent
>[]
Inherited from
Source
isDrawable
isDrawable:
boolean
=true
Overrides
Source
isShape
isShape:
boolean
=false
Inherited from
Source
isText
isText:
boolean
=true
Overrides
Source
layout
layout:
Layout
={}
FOR INTERNAL USE ONLY
Implementation of
Inherited from
Source
localizedFontName
private
localizedFontName:undefined
|string
Source
localizedFontNames
private
localizedFontNames:string
[] =[]
Source
loopMessages
loopMessages:
Set
<string
>
Inherited from
Source
name
name:
string
Name of the node. Only needed if the node will be referred to by name in a later function
Implementation of
Inherited from
Source
needsInitialization
needsInitialization:
boolean
=true
Inherited from
Source
nodeEvents
Inherited from
Source
options
options:
M2NodeOptions
Inherited from
Source
paraStyle?
private
optional
paraStyle:ParagraphStyle
Source
paragraph?
private
optional
paragraph:Paragraph
Source
parent?
optional
parent:M2Node
Inherited from
Source
pressed
pressed:
boolean
=false
Is the node in a pressed state? E.g., did the user put the pointer down on the node and not yet release it?
Inherited from
Source
pressedAndWithinHitArea
pressedAndWithinHitArea:
boolean
=false
Is the node in a pressed state AND is the pointer within the node's hit area? For example, a user may put the pointer down on the node, but then move the pointer, while still down, beyond the node's hit area. In this case, pressed = true, but pressedAndWithinHitArea = false.
Inherited from
M2Node
.pressedAndWithinHitArea
Source
pressedInitialPointerOffset
pressedInitialPointerOffset:
Point
When the node initially enters the pressed state, what is the pointer offset? (offset from the canvas's origin to the pointer position). We save this because it will be needed if this press then led to a drag.
Inherited from
M2Node
.pressedInitialPointerOffset
Source
queuedAction?
optional
queuedAction:Action
Inherited from
Source
type
readonly
type:Label
=M2NodeType.Label
Overrides
Source
userData
userData:
any
={}
Inherited from
Source
uuid
Internal
readonly
uuid:string
Unique identifier (UUID). Will be generated automatically. For m2c2kit library use only
Implementation of
Inherited from
Source
withinHitArea
withinHitArea:
boolean
=false
Inherited from
Source
Accessors
alpha
get
alpha():number
Opacity of the node. 0 is fully transparent, 1 is fully opaque. Default is 1.0. Alpha has multiplicative inheritance. For example, if the node's parent is alpha .5 and this node's is alpha .4, then the node will appear with alpha .2.
set
alpha(alpha
):void
Opacity of the node. 0 is fully transparent, 1 is fully opaque. Default is 1.0. Alpha has multiplicative inheritance. For example, if the node's parent is alpha .5 and this node's is alpha .4, then the node will appear with alpha .2.
Parameters
• alpha: number
Returns
number
Source
ancestors
get
ancestors():M2Node
[]
Returns all ancestor nodes, not including the node itself.
Returns
M2Node
[]
Source
anchorPoint
get
anchorPoint():Point
Point within the node that determines its position. Default is { x: 0.5, y: 0.5 }, which centers the node on its position
set
anchorPoint(anchorPoint
):void
Point within the node that determines its position. Default is { x: 0.5, y: 0.5 }, which centers the node on its position
Parameters
• anchorPoint: Point
Returns
Source
backgroundColor
get
backgroundColor():undefined
|RgbaColor
Background color of label text. Default is no background color
set
backgroundColor(backgroundColor
):void
Background color of label text. Default is no background color
Parameters
• backgroundColor: undefined
| RgbaColor
Returns
undefined
| RgbaColor
Source
backgroundPaint
get
private
backgroundPaint():Paint
set
private
backgroundPaint(backgroundPaint
):void
Parameters
• backgroundPaint: Paint
Returns
Paint
Source
canvasKit
get
canvasKit():CanvasKit
Gets the scene that contains this node by searching up the ancestor tree recursively. Throws exception if node is not part of a scene.
Returns
CanvasKit
Scene that contains this node
Source
completeNodeOptions
get
completeNodeOptions():object
Returns
object
alpha?
optional
alpha:number
Opacity of the node. 0 is fully transparent, 1 is fully opaque. Default is 1.0. Alpha has multiplicative inheritance. For example, if the node's parent is alpha .5 and this node's is alpha .4, then the node will appear with alpha .2.
anchorPoint?
optional
anchorPoint:Point
Point within the node that determines its position. Default is { x: 0.5, y: 0.5 }, which centers the node on its position
backgroundColor
backgroundColor:
undefined
|RgbaColor
draggable?
optional
draggable:boolean
Can the node be dragged?
fontColor?
optional
fontColor:RgbaColor
Color of text. Default is Constants.DEFAULT_FONT_COLOR (WebColors.Black)
fontName?
optional
fontName:string
Name of font to use for text. Must have been previously loaded
fontNames
fontNames:
undefined
|string
[]
fontSize?
optional
fontSize:number
Size of text. Default is Constants.DEFAULT_FONT_SIZE (16)
hidden?
optional
hidden:boolean
Is the node, and its children, hidden? (not displayed). Default is false
horizontalAlignmentMode
horizontalAlignmentMode:
LabelHorizontalAlignmentMode
interpolation?
optional
interpolation:StringInterpolationMap
Map of placeholders to values for use in string interpolation during localization.
isUserInteractionEnabled?
optional
isUserInteractionEnabled:boolean
Does the node respond to user events, such as taps? Default is false
layout?
optional
layout:Layout
FOR INTERNAL USE ONLY
localize?
optional
localize:boolean
If true, try to use a localized version of the text. Default is true.
name?
optional
name:string
Name of the node. Only needed if the node will be referred to by name in a later function
position?
optional
position:Point
Position of the node within its parent coordinate system. Default is (0, 0)
preferredMaxLayoutWidth
preferredMaxLayoutWidth:
undefined
|number
scale?
optional
scale:number
Scale of the node. Default is 1.0
suppressEvents?
optional
suppressEvents:boolean
Should the node not emit events to the EventStore? Default is false.
Remarks
This property is for use by authors of Composite
nodes. It is not intended for general use.
text?
optional
text:string
Text to be displayed
uuid?
Internal
optional
uuid:string
Unique identifier (UUID). Will be generated automatically. For m2c2kit library use only
zPosition?
optional
zPosition:number
Value along the z-axis to determine drawing and tap order. Larger values are on top.
zRotation?
optional
zRotation:number
Rotation of the node around the Z axis. Unit is radians. Default is 0 (no rotation). zRotation has inheritance. In addition to this node's zRotation, all ancestors' zRotations will be applied.