#Using custom sprite font instead of font - Mimpy Dialogue Tutorial

43 messages · Page 1 of 1 (latest)

solar canyon
#

Mainly one for @little ferry

I'm following your dialogue tutorial (thanks to the person who hooked me up) since a different tutorial is causing me issues. I have a couple of questions since I'm not going to follow it to the T.

Instead of using a Font (Alt + F), I wanted to use a custom font I created which is a sprite. Is it as simple as having the variable in the Create event for obj_textbox text_font = spr_main_font;?

Do I need to do something different in the Draw GUI event as well? As I imagine I can't use draw_set_font(text_font); since I'm technically using a sprite and not a font.

I've attached some images, hope it makes things clearer.

Thank you, and appreciate you helping out the community with these tutorials :)

#

Or is there some magic where I import that sprite as an actual font, and then all of this can be followed as normal? I'll stop asking questions now =D

dusty lanternBOT
#

With this function you can use a "sprite strip" (the sprite itself must be a sprite asset from the Asset Browser, or a sprite you have added to the game resources using sprite_add) to create a new font asset, where each sub-image would be an individual symbol or letter. Unlike the normal font_add_sprite() which has a specific order for the sub-images of the sprite, this function will map the sprite sub-images based on the argument "string_map" of the function. This argument is a string that you can use to tell GameMaker what order the sub-images of the sprite font are and it will map these automatically when writing text. So, for example, if you have a string-map of "AaBbCcDdEeFfGgHh", your sprite font must have the sub-images ordered in this way. You can define "space" as being any character you want, for example a single line the size that you want the space to be, and all spaces in text will be rendered at that width (but the image chosen will never be rendered), or if you don't supply a sprite for space then the width of the widest character in the sprite font will be used instead.

Arguments
spr: The sprite to add a font based on.
string_map: String from which sprite sub-image order is taken.
prop: Set as proportional font or not.
sep: The space to leave between each letter.

solar canyon
#

Thank you @stark mango duckycode

solar canyon
#

Bumping this since I'm encountering some issues. Sorry in advance.

Followed up to obj_demo in the vid, and gave this a test run. My dialogue box appears around the bottom right + appears to have not scaled correctly + not animate, and the text hasn't changed to the custom sprite text. I think I'm probably misunderstanding font_add_sprite_ext,

I've attached images of the Create + Draw GUI events for obj_settings, and the sprite I'm using for my textbox. If you need anything else to debug let me know. Thank you :)

stark mango
#

not animating is because you inputted 0 as the frame. put image_index

#

where's font_add_sprite_ext

#

what's the top of your creat eevent look like, from lines 1 - 11

#

i also don't see a draw_set_font

solar canyon
#

oop sorry lemme get that for you

solar canyon
solar canyon
stark mango
#

right

#

ok let's deal with the font first

#

so

#

you don't want it in the draw event

#

you actually almost had it here

#

text_font = font_add_sprite_ext(...)

#

and then darw_set_font(text_font) in draw event

solar canyon
#

ohhh

#

genius

stark mango
#

now

your font_add_sprite_ext is also wrong

#

read the example on the documenation page

#

please make it a habit of reading the docs

#

specifically the ord("!") part

solar canyon
#

gotcha

stark mango
#

as for the positioning

#

this is yours

#

this is mimpy's

#

what's different?

the parentheses

#

if you remember BODMAS/PEMDAS/whatever you were taught

#

yours, that /2 only applies to width

in mimpy's he put ( ) around it, so it applies to the whole subtraction

solar canyon
# stark mango specifically the ``ord("!")`` part

am i on the right track here?

text_font = font_add_sprite_ext(spr_main_font, "!#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~", true, 1);

when i run it, it writes the correct font. but when it gets to the lower case chars, it's behind by 1 character.

Hello World writes as Hdkkn Wnqkc!

the string in font_add_sprite adds up to 93 chars. the amount of frames in my font is 93 as well (ended up removing the frame that acts as a space, and the " as it kept messing up the string when i put it in " " marks)

stark mango
#

Check your string map again and make sure it matches your sprite

#

Oh yknow what it is

#

Its the slash

#

\ signifies a special character is coming next

#

So to have a slash, actually need two \

solar canyon
#

insane spot thank you lemme see if that works

#

because i quadruple checked the string map vs the sprite