Prev | Current Page 990 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

ttf???;
var ptSize : Int = ???12???;
var location : Point = new Point( 10, 10 );
var fgColor : Int = 0xFFFFFF;
var bgColor : Int = 0x000000;
var alpha : Int = 100;
TTF.draw( textStr, font, ptSize, location, fgColor, bgColor, alpha );
The parameters are fairly self - explanatory. The first parameter is the string you want written to the
Surface . This can be as long as you like, though the window only has so much real estate. From there,
the parameters deal with the font file you wish to use, the size of the font to display on screen in
pixels, the location to print the text as a Point instance, the foreground and background colors, and the
alpha value of the displayed text, respectively. When choosing colors for the text, the background has to
be rendered to screen, unfortunately, though you can avoid this issue using color keys described later in
this chapter.
Working with Surfaces
All data written to the display buffer, whether graphical or textual, is done so using a Surface object.
Surface s provide a great way to interlink all assets in your NME applications, and allow for rendering
to be performed on any visible object, seeing as the Surface class represents the only visible object type.


Pages:
978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002