Created
February 1, 2015 23:49
-
-
Save coronarob/e7790a212bce618199c7 to your computer and use it in GitHub Desktop.
Code from Tutorial: Methods for Positioning Text (http://coronalabs.com/blog/2014/02/11/tutorial-methods-for-positioning-text/)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local myText = display.newText( "Hello World", 200, 200, native.systemFont, 16 ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local myText = display.newText( "Hello World", 0, 0, native.systemFont, 16 ) | |
myText:setFillColor( 0, 0, 0 ) | |
myText.anchorX = 0 | |
myText.x = 10 | |
myText.y = 100 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local options = { | |
text = "Hello World", | |
x = display.contentCenterX, | |
y = display.contentCenterY, | |
fontSize = 24, | |
width = 200, | |
height = 0, | |
align = "left" | |
} | |
local textBox = display.newText( options ) | |
textBox:setFillColor( 0, 0, 0 ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local myText = [[This is a long, multi-line string where we are randomly | |
inserting some blank | |
lines | |
of text.]] | |
local options = { | |
text = myText, | |
x = display.contentCenterX, | |
y = display.contentCenterY, | |
width = 200, | |
height = 300, | |
fontSize = 24, | |
align = "left" | |
} | |
local textField = display.newText( options ) | |
textField:setFillColor( 0, 0, 0 ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local myText = [[This is a long, multi-line string where we are randomly | |
inserting some blank | |
lines | |
of text.]] | |
local options = { | |
text = myText, | |
x = display.contentCenterX, | |
y = display.contentCenterY, | |
width = 200, | |
height = 300, | |
fontSize = 24, | |
align = "center" | |
} | |
--Output the text box with the specified options | |
local textField = display.newText( options ) | |
textField:setFillColor( 0, 0, 0 ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local myText = [[This is a long, multi-line string where we are randomly | |
inserting some blank | |
lines | |
of text.]] | |
local options = { | |
text = myText, | |
x = display.contentCenterX, | |
y = display.contentCenterY, | |
width = 200, | |
height = 300, | |
fontSize = 24, | |
align = "right" | |
} | |
--Output the text box with the specified options | |
local textField = display.newText( options ) | |
textField:setFillColor( 0, 0, 0 ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
longString = [[This is a really | |
long string | |
with multiple | |
line breaks.]] | |
--OR... | |
longString = "This is a really\nlong string\nwith multiple\nline breaks." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment