Overview
Creates a text object using true-type font.
Text class inherits Display class, therefore all the methods defined in Display class can also be used in the Circle object.
Syntax
local t = Text(string [,option] ) |
• string - (required) text string to show
• option - (optional) table for extra parameters
{ font = 'name', -- (optional) font name
fontSize = n, --(optional) font size
color = color, -- (optional) text color (Color object)
}
Note that the initial anchor point is the center of the center of the whole text body.
The available true-type fonts are as follows:
• 'opensans' (default font)
• 'typed'
• 'cabin'
• 'cruft'
• 'consolas'
These are located in luasopia/ttf folder and are all public domain fonts.
Methods
method | description |
obj:setFont(name [, n]) | set (true-type) font and font size n (font size can be omitted) |
obj:setColor(color) | set color of the text (color is a Color object) |
obj:setString(str) | change text as str (string) |
obj:setFontSize(n) | change font size as n |
obj:getFontSize() | get current font size |
obj:getString() | get current string |
Examples
local t = Text('Hi luasopia',{fontsize=100, color=Color.RED}):setXY(100,200) |
local t = Text('Rotate!'):setDrot(1) Timer(2000, function() t:setColor(Color.RED) end) -- change text color after 2 seconds Timer(4000, function() t:setFontSize(100) end) -- change font size after 4 seconds |
local g = Group():setDrot(1) local t1=Text('Hi'):addTo(g) local t2 = Text('all',{fontsize=100},g):setY(100) |
댓글 없음:
댓글 쓰기