Is there an expression for the x,y location of the character in a string?

R

Rosieu

Guest
Hi Everyone!

I was wondering if there was a way to handle/find the x,y coordinates of a character at a given location in a string?

To give it some context, I'm currently adapting Heartbeast's dialogue tutorial to my own uses and I was wondering if there is a way I could basically tell my game to draw a sprite at a location, based on the location of a character in a string.
Say for example, the index of the character was "count" (which it is at this time thanks to Heartbeast's tutorial), is there a way I could say something like:

draw_sprite(spr_example,0,(string_char_at(message,count).x +10),(string_char_at(message,count).y))?

So that the game would draw the sprite at the location of the character at point 'count' in string 'message' (+ 10 pixels across).

Thanks in advance for everyone's help!
 
W

whale_cancer

Guest
No in-built function (AFAIK) so you would have to write your own. Not hard if you are using a fixed width font, not too much harder if you are not.
 
D

Drewster

Guest
I don't think there's any super easy way to do this. If you wanted the location of say, the 15th character of a string, maybe you can do something with string_width just using the first 14 characters, and add that to the left X position, etc.. sounds like a pain.
 
R

Rosieu

Guest
Hmmm, I did some fiddling based on the information and I couldn't exactly get anything manageable going. That being said I have a work around / different way of doing things that looks fine. Thanks for all your help though! :D
 
Top