How to find the exact coordinates of 'Say' text? (SOLVED)

Started by EnterTheStory (aka tolworthy), Thu 29/05/2008 11:55:27

Previous topic - Next topic

EnterTheStory (aka tolworthy)

Is there any way to find out exactly where 'Say' will place its text?

Failing that, any idea how 'Say' decides the height above a character's head and the width of a line?

Failing that, is there something like 'SayAt' that works with 'SayBackground'?

(I'm trying to position a transparent balloon character behind text, for better visibility.)

monkey0506

#1
AFAIK the text is centered around the Character's x-coordinate, so something like:

(nevermind)

I'm not sure about the y-coordinate off the top of my head, but I think it's been discussed before. I've definitely done something like this before, but I'm not sure if I specifically asked about it on the forums or just used brute force attacks to try and match the built-in system. :P

Edit: Wait, you meant the width that AGS uses to determine the maximum width of each line of text...sorry about that. I did something with this before but I don't have access to the scripts at the time. I'm searching the forums for related articles now.

Ah yes...

Quote from: Pumaman on Thu 11/10/2007 21:28:16The default overlay width is 3/4 of the screen; for lucasarts-style speech it is 4/6.
If the character is within 1/4 of the edge of the screen, the width is reduced by 1/5.

So the width and the x should be something like this:

Code: ags
String text = "blah blah blah";
int width = (System.ViewportWidth * 3) / 4;
if ((player.x <= (width / 3)) || (player.x >= width)) width -= System.ViewportWidth / 5;
int x = player.x - (width / 2);
if ((x + (width / 2)) > System.ViewportWidth) x = System.ViewportWidth - width;


That also compensates for the borders of the screen as well. However there's no GetSpeechStyle function (it's been suggested), so you would need to know if you're using LA-style speech.

EnterTheStory (aka tolworthy)

Many thanks. That is extremely useful to know!

SMF spam blocked by CleanTalk