Past 6 – First Steps – Text

Introduction to Mobile Game Development

Written July, 2015, by Rachel J. Morris

Creative Commons License Introduction to Mobile Game Development by Rachel J. Morris is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. Based on a work at

Return to the main page

When writing text in your application, you’re going to need a font. You can either load in a .ttf file, or use the Gideros Font Creator to prepare fonts to be used in the program. We are going to keep it simple and just load .ttf files!

You can find free-to-use fonts at Open Font Library, though make sure you keep in mind the license. Some font creators want credit for their work, and some do not require it. The same applies for when you’re using someone else’s music or art as well. (Always ask or check the license!)

Put the .ttf file somewhere within your project folder on the hard drive, and import it into your Gideros project.

Simply load the font into a variable like this:

font = "Amburegul.ttf", 30 )

Then, we can create a TextField object that uses the TTFont.  This is similar to how we would load a Texture for a Bitmap, where we could manipulate the Bitmap‘s position and appearance.

We can create a TextField and output it to the screen like this:

font = "fonts/Amburegul.ttf", 30 )

label = font, "Welcome to" )
label:setPosition( 25, 50 )
stage:addChild( label )

label2 = font, "my project" )
label2:setPosition( 25, 100 )
stage:addChild( label2 )


Set text color

We can also adjust the text color with the setTextColor function:

label:setTextColor( 0xFF0000 )

To get a hex value for the color, I would suggest using GIMP, choosing a color from the color picker, and it will give you the hex value below. gimp

On the class GitHub page, there are two projects with sample code for text:

Also check out the related Gideros documentation:

Print Friendly