Version: beta
FUNCTIONS | |
---|---|
label.get_text() | gets the text for a label |
label.set_text() | set the text for a label |
PROPERTIES | |
---|---|
color | vector4 label color |
font | hash label font |
leading | number label leading |
line_break | bool label line break |
material | hash label material |
outline | vector4 label outline |
scale | number | vector3 label scale |
shadow | vector4 label shadow |
size | vector3 label size |
tracking | number label tracking |
label.get_text(url)
Gets the text from a label component
PARAMETERS
url |
string, hash, url |
the label to get the text from |
RETURNS
metrics |
string | the label text |
EXAMPLES
function init(self)
local text = label.get_text("#label")
print(text)
end
label.set_text(url,text)
Sets the text of a label component
This method uses the message passing that means the value will be set after dispatch messages
step.
More information is available in the Application Lifecycle manual.
PARAMETERS
url |
string, hash, url |
the label that should have a constant set |
text |
string |
the text |
EXAMPLES
function init(self)
label.set_text("#label", "Hello World!")
end
The color of the label. The type of the property is vector4.
EXAMPLES
function init(self)
-- Get the current color's y component
local red_component = go.get("#label", "color.y")
-- Animate the color
go.animate("#label", "color", go.PLAYBACK_LOOP_PINGPONG, vmath.vector4(0,1,0,1), go.EASING_INOUTSINE, 1)
end
The font used when rendering the label. The type of the property is hash.
EXAMPLES
How to set font using a script property (see resource.font)go.property("my_font", resource.font("/font.font"))
function init(self)
go.set("#label", "font", self.my_font)
end
The leading of the label. This value is used to scale the line spacing of text. The type of the property is number.
EXAMPLES
How to query a label's leading:function init(self)
-- get leading from component "label"
local leading = go.get("#label", "leading")
-- do something useful
leading = leading * 1.2
go.set("#label", "leading", leading)
end
The line break of the label. This value is used to adjust the vertical spacing of characters in the text. The type of the property is boolean.
EXAMPLES
How to query a label's line break:function init(self)
-- get line_break from component "label"
local line_break = go.get("#label", "line_break")
-- do something useful
go.set("#label", "line_break", false)
end
The material used when rendering the label. The type of the property is hash.
EXAMPLES
How to set material using a script property (see resource.material)go.property("my_material", resource.material("/material.material"))
function init(self)
go.set("#label", "material", self.my_material)
end
The outline color of the label. The type of the property is vector4.
EXAMPLES
function init(self)
-- Get the current outline color
local outline = go.get("#label", "outline")
-- Animate the property
go.animate("#label", "outline", go.PLAYBACK_LOOP_PINGPONG, vmath.vector4(0,1,0,1), go.EASING_INOUTSINE, 1)
end
The scale of the label. The type of the property is number (uniform) or vector3 (non uniform).
EXAMPLES
How to scale a label independently along the X and Y axis:function init(self)
-- Double the y-axis scaling on component "label"
local yscale = go.get("#label", "scale.y")
go.set("#label", "scale.y", yscale * 2)
-- Set the new scale altogether
go.set("#label", "scale", vmath.vector3(2,2,2))
-- Animate the scale
go.animate("#label", "scale", go.PLAYBACK_LOOP_PINGPONG, vmath.vector3(2,2,2), go.EASING_INOUTSINE, 1)
end
The shadow color of the label. The type of the property is vector4.
EXAMPLES
function init(self)
-- Get the current shadow color
local shadow = go.get("#label", "shadow")
-- Animate the property
go.animate("#label", "shadow", go.PLAYBACK_LOOP_PINGPONG, vmath.vector4(0,1,0,1), go.EASING_INOUTSINE, 1)
end
Returns the size of the label. The size will constrain the text if line break is enabled. The type of the property is vector3.
EXAMPLES
How to query a label's size, either as a vector or selecting a specific dimension:function init(self)
-- get size from component "label"
local size = go.get("#label", "size")
local sizex = go.get("#label", "size.x")
-- do something useful
assert(size.x == sizex)
end
The tracking of the label. This value is used to adjust the vertical spacing of characters in the text. The type of the property is number.
EXAMPLES
How to query a label's tracking:function init(self)
-- get tracking from component "label"
local tracking = go.get("#label", "tracking")
-- do something useful
tracking = tracking * 1.2
go.set("#label", "tracking", tracking)
end