Using sprite fonts on GM1. Creating your font1. Create a sprite with the font on it, make sure that the font is on
ASCII order.
2. Create a global variable or a constant to use the font.
-
2.1. Using a global variable
Using gml Syntax Highlighting
global._font = font_add_sprite(spr_font,ord('!'),true,0)
Make sure to add "ord('!')" in
argument1. Otherwise the font will not work properly.
-
2.2. Using a constant variable
If you want to use a constant, go to "Resources > Define Constants" and a window will appear. Look the following image to see how to make it.
2. Using the fontIf you want to use the sprite you added as a font. Follow the following steps.
1. Using a global variable.
Using gml Syntax Highlighting
draw_set_font(global._font)
draw_set_color(c_white)
draw_set_alpha(1)
{
<your code>
}
2. Using a constant variable.
Using gml Syntax Highlighting
draw_set_font(c_font)
draw_set_color(c_white)
draw_set_alpha(1)
{
<your code>
}
Make sure to add "draw_set_color(c_white)". Otherwise all the text will get color
BLACK automatically. Make sure you add this code on a
Draw event.
NOTE: This tutorial only works with the Pro / Standard version of Game Maker.
[size=200][b]Using sprite fonts on GM[/b][/size]
[u][b]1. Creating your font[/b][/u]
[b]1.[/b] Create a sprite with the font on it, make sure that the font is on [url=http://en.wikipedia.org/wiki/ASCII]ASCII[/url] order.
[b]2.[/b] Create a global variable or a constant to use the font.
-[b]2.1.[/b] Using a global variable
[syntax=gml]global._font = font_add_sprite(spr_font,ord('!'),true,0)[/syntax]
Make sure to add "ord('!')" in [b]argument1[/b]. Otherwise the font will not work properly.
-[b]2.2.[/b] Using a constant variable
If you want to use a constant, go to "Resources > Define Constants" and a window will appear. Look the following image to see how to make it.
[img]http://i.imgur.com/kIUC2.png[/img]
[u][b]2. Using the font[/b][/u]
If you want to use the sprite you added as a font. Follow the following steps.
[b]1.[/b] Using a global variable.
[syntax=gml]draw_set_font(global._font)
draw_set_color(c_white)
draw_set_alpha(1)
{
<your code>
}[/syntax]
[b]2.[/b] Using a constant variable.
[syntax=gml]draw_set_font(c_font)
draw_set_color(c_white)
draw_set_alpha(1)
{
<your code>
}[/syntax]
Make sure to add "draw_set_color(c_white)". Otherwise all the text will get color [b]BLACK[/b] automatically. Make sure you add this code on a [b]Draw[/b] event.
[b]NOTE:[/b] [i]This tutorial only works with the [b]Pro[/b] / [b]Standard[/b] version of Game Maker.[/i]