Difference between revisions of "TexturePackFont.new"
From GiderosMobile
m (Text replacement - "<source" to "<syntaxhighlight") |
m (Text replacement - "</source>" to "</syntaxhighlight>") |
||
Line 6: | Line 6: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
TexturePackFont.new(texturePack,mappings,scale,anchor) | TexturePackFont.new(texturePack,mappings,scale,anchor) | ||
− | </ | + | </syntaxhighlight> |
=== Parameters === | === Parameters === | ||
Line 28: | Line 28: | ||
stage:addChild(tf2) | stage:addChild(tf2) | ||
stage:addChild(tf3) | stage:addChild(tf3) | ||
− | </ | + | </syntaxhighlight> |
{{TexturePackFont}} | {{TexturePackFont}} |
Latest revision as of 14:33, 13 July 2023
Available since: Gideros 2021.9
Class: TexturePackFont
Description
Creates a new TexturePackFont object.
TexturePackFont.new(texturePack,mappings,scale,anchor)
Parameters
texturePack: (TexturePack) the TexturePack object that will be wrapped in this font
mappings: (table) a character to filename map to associate characters with TexturePack images
scale: (double) a scale factor to apply to the texture pack images (default = 1)
anchor: (double) where the images should be laid relative to the text baseline (default = 1)
Example
Try to simulate arabic letters
local tp = TexturePack.new({"fonts/ar_ba.png", "fonts/ar_ta.png", "fonts/ar_tha.png"}) -- path to png images
local font = TexturePackFont.new(tp, {ba="fonts/ar_ba.png", ta="fonts/ar_ta.png", sa="fonts/ar_tha.png"}, 3, 0) -- tp, mappings, scale, anchory
local tf = TextField.new(font, "bata")
local tf2 = TextField.new(font, "taba sa")
local tf3 = TextField.new(font, "sa")
tf:setPosition(64*6, 64*1)
tf2:setPosition(64*6, 64*2)
tf3:setPosition(64*6, 64*3)
stage:addChild(tf)
stage:addChild(tf2)
stage:addChild(tf3)