Author Topic: How do I move where speech is displayed and typewriter scrawl.  (Read 637 times)

Armageddon

  • Posts: 1,443
  • Likes apples and nuts
Hi, I'm wanting to make all speech be displayed in the top left corner like old Lucas Arts games and also not be centered but aligned to the left. Can you even move how the speech text is displayed?

Also I'm wondering how you would make the speech type out like a typewriter?

Thanks.

Slasher

  • Posts: 2,756
  • slasher
    • I can help with AGS tutoring
    • Lifetime Achievement Award Winner
    • I can help with scripting
    • I can help with story design
    • Slasher worked on a game that was nominated for an AGS Award!
Hi,

To have the text align left you could use:

Code: Adventure Game Studio
  1. game.speech_text_align=eAlignLeft;

To Display text in a certain area you could use:

Code: Adventure Game Studio
  1. cEgo.SayAt(220, 20, 100, "My name is ego"); // Left, Top, Length, Text
  2.  

You could also look at using a GUI with label to display the speech, as for typewriting text do a search for typewriter as there are a few answers to that very question.

Hope you find the right solution


geork

  • Posts: 210
  • measure once, cut twice, say it was already broken
    • I can help with scripting
    • I can help with voice acting
For the typewritten speech, you could do this, although it's a bit more hassle: you'll have to use a custom function (I prefer extender function) for speech instead of using commands like 'Say()' and have that typewrite. you'll probably want a while loop within the function that truncates the string to a lesser and lesser degree every so-many game loops. Maybe something like:
Code: Adventure Game Studio
  1. void Comment(this Character*, String m){ //extender function
  2.   this.StopMoving();
  3.   Overlay* bgs;
  4.   this.LockView(this.SpeechView);
  5.   this.Animate(this.Loop, 3, eRepeat, eNoBlock, eForwards);
  6.   int timer = ((m.Length/Game.TextReadingSpeed + 1) * GetGameSpeed())/m.Length; //get how long every wait should be
  7.                                                                                 //the reason this has to be calculated
  8.                                                                                 //is because AGS calculates speech time
  9.                                                                                 //in 15 character - 40 game loop steps
  10.   int i = 1;
  11.   while (i<=m.Length){
  12.     bgs = this.SayBackground(m.Truncat(i));
  13.     Wait(timer);
  14.     i ++;
  15.   }
  16.   if (bgs != null && bgs.Valid) bgs.Remove();
  17.   this.UnlockView();
  18. }
  19. //then to call it
  20. cChar.Comment("Blah");
!This is thoroughly untested!
 The only problem is that this is not skippable. Also, you can't control where the command is put. For that, you may want to change the code like this:
Code: Adventure Game Studio
  1. void CommentAt(this Character*, String m, int X, int Y, int Width, int ColorIndex){ //extender function
  2.   this.StopMoving();
  3.   Overlay* bgs = Overlay.CreateTextual(X,Y,Width, Game.SpeechFont, ColorIndex, ""); //initialize the overlay to display a text
  4. ;
  5.   this.LockView(this.SpeechView);
  6.   this.Animate(this.Loop, 3, eRepeat, eNoBlock, eForwards);
  7.   int timer = ((m.Length/Game.TextReadingSpeed + 1) * GetGameSpeed())/m.Length; //get how long every wait should be
  8.                                                                                 //the reason this has to be calculated
  9.                                                                                 //is because AGS calculates speech time
  10.                                                                                 //in 15 character - 40 game loop steps
  11.   int i = 1;
  12.   while (i<=m.Length){
  13.     String s = m.Truncate(i);
  14.     bgs.SetText(Width, Game.SpeechFont, ColorIndex, s); //change the text to the truncated string
  15.     Wait(timer);
  16.     i ++;
  17.   }
  18.   if (bgs != null && bgs.Valid) bgs.Remove();
  19.   this.UnlockView();
  20. }
  21. //then to call it
  22. cChar.CommentAt("Blah", 200, 200, 200, 15);

!Again: thoroughly untested!
  This isn't the most optimized solution I'm sure, but it's something to start on.

 Hope that helps! :)

 EDIT: Oops, just realized the maths was wrong for the loop. now fixed
« Last Edit: 20 Apr 2013, 16:08 by geork »