Text Overlay & String Text [SOLVED]

Started by Arjunaz78, Sat 17/09/2011 21:11:03

Previous topic - Next topic

Arjunaz78

I've follow the densming video ags tutorial,but i don't know how to make a string text other than center position,but i've done with the 'showtextcenter' function,but what about if i want the text display at the top or the bottom screen?plus i want to make a break line point of text or should i say paragraph (???...sorry if i'm wrong) for my long text.

Is it means i need a different string text or what??

p.s: sorry for my bad English.
..In the making of Silent Hill: The Hospital..

https://www.facebook.com/ArjunazGamesStudio

Khris

Check out the different Say functions in the manual.

A line break is [ afaik.

Arjunaz78

I've already know about using the different Say funtions in the manual,but actually what i means is the 'Overlay* textOverlay' functions that includes the 'showtextcenter' syntax.I want to change the text overlay display on other position (coordinates).Is it i just need to changes a ' X,Y ' positions for the top & bottom positions (coordinates) while a syntax still 'showtextcenter' names on it and just ignore the 'center' names of 'showtextcenter' syntax?

Overlay* textOverlay = Overlay.CreateTextual(50,80,+ y, Game.SpeechFont, 15,"This is a text overlay");
Wait(40);
textOverlay.Remove();

can i use the syntax like above to positoning (coordinating) my text display?
..In the making of Silent Hill: The Hospital..

https://www.facebook.com/ArjunazGamesStudio

monkey0506

I'm not sure if I understand the issue entirely here, but if you're trying to position character speech then use the SayAt function, which allows you to specify a coordinate (X, Y) at which the top-left corner of the speech will appear. This will also run the character's speech view if appropriate (AFAIK).

If you're not talking about character speech, then you can create the overlay manually which you already seem to know how to do, but you seem confused about how to position the overlay...? If that's the case, the first two parameters to both of the overlay create methods are the coordinates (X, Y) at which the top-left corner of the overlay will be displayed. So if you wanted to display a message 5 px above the bottom of the screen, centered horizontally it would look something like this:

Code: ags
String text = "This is some text.";
int width = GetTextWidth(text, Game.NormalFont);
int height = GetTextHeight(text, Game.NormalFont, width);
int x = (System.ViewportWidth - width) / 2; // center the text horizontally on-screen, based on the width of the text and screen
int y = System.ViewportHeight - 5 - height; // set the text position to end 5 px above the bottom of the screen, the actual Y is then offset by the height of the text
Overlay *textOverlay = Overlay.CreateTextual(x, y, width, Game.NormalFont, 15, text);
Wait(GetGameSpeed() * 3); // wait for exactly 3 seconds
textOverlay.Remove();


If you're doing this several times it would be worth creating a custom function, but it would be somewhat less useful if you don't understand what it's doing. You already seem to understand, at least slightly, that the Overlay.CreateTextual function is what you need, but you need to understand the parameters too since they control what's on the overlay, where it's displayed, etc. Once an overlay is created you can also reposition it using the Overlay.X and Overlay.Y properties while the overlay remains valid (Overlay.Valid will be true).

Oh, and what is "showtextcenter"?? Is that a custom function that densming created for his tutorials??

Adrian

"ShowTextCentered" is a simple function densming created in one of his videos to center Text on the screen:

http://www.youtube.com/watch?v=79yTq3BQo14

Code: ags

Overlay *textOverlay;

function ShowTextCentered(String text) {
	int centerX, centerY;
	int textWidth, textHeight;
	int x, y;

	centerX = System.ViewportWidth / 2;
	centerY = System.ViewportHeight / 2;

	textWidth = GetTextWidth(text, Game.NormalFont);
	textHeight = GetTextHeight(text, Game.NormalFont, textWidth);

	x = centerX – (textWidth / 2);
	y = centerY – (textHight / 2);

	textOverlay = Overlay.CreateTextual(x, y, textWidth + 7, Game.NormalFont, 7, text);
}




@Arjunaz78: This function is handy if you want to place a centered TextOverlay in the screen but you shouldn't use it in general to put text on screen by playing around with the values for position. Better use Khris' and monkey's hints to do it. That's more straight forward.

@monkey: Funny you ask about the function because you helped densming creating it :-) :

http://www.adventuregamestudio.co.uk/yabb/index.php?topic=35731.0



Dualnames

@Adrian: It's clear that i have access to monkey's account and i like to roleplay from time to time :P
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

monkey0506

Hah, you wish Dual. Bet that's right up there on your list with becoming best friends with Douglas Adams' ghost!

Back on topic though, Arjunaz, did this help you resolve your problem?

Arjunaz78

Yeah..thanks monkey's..now i understand this code more clearly although sometimes it is misleading/confusing to me..

I have been using the code you provided, and it works perfectly..

Code: ags

String text = "This is some text.";
int width = GetTextWidth(text, Game.NormalFont);
int height = GetTextHeight(text, Game.NormalFont, width);
int x = (System.ViewportWidth - width) / 2; 
int y = System.ViewportHeight - 5 - height; 
Overlay *textOverlay = Overlay.CreateTextual(x, y, width, Game.NormalFont, 15, text);
Wait(GetGameSpeed() * 3);
textOverlay.Remove();


But i facing some trouble when using & add a '[' symbol that LeKhris have been told me before to make a line break.But what the really i want,is to use the paragraph on the text display like this..

Code: ags

   This is the text

     Hello World

but not like this..

This is the text

Hello World


So i want the second text display at the center of second paragraph below the first text display and not the left side.
Nevertheless, i've force to add a 'space' on my text display plus using the '[' symbol.
but it is always difficult to using it or add it when placing on the center of X,Y position..

It's seems always move to left side of screen and the text sometimes becomes long length and sequence in a row..

sorry for making you feel confused by this problem, but I will posts the pictures & scripting codes later on my next posts.

p.s - Once again,sorry for my bad 'ENGLISH'

TY.
..In the making of Silent Hill: The Hospital..

https://www.facebook.com/ArjunazGamesStudio

SMF spam blocked by CleanTalk