Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: .M.M. on Sun 30/09/2007 13:14:31

Title: Speech animation
Post by: .M.M. on Sun 30/09/2007 13:14:31
I'm using top bars instead normal dialogs. How can I simply add speech animation for characters?
Title: Re: Speech animation
Post by: Ashen on Sun 30/09/2007 13:56:29
Just to be clear, are you using DisplayTopBar (which seems likely based on this earlier post (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=32442.0))?

If so, what have you tried, and what's wrong with the results?
Character.Animate seems to work just fine, e.g.:

player.Animate(player.Loop,3, eRepeat, eNoBlock);
DisplayTopBar(50,14,1986,"Roger", "Hello there!");
player.ChangeView(player.View); // This stops the aniamtion from running.


Obviously, that doesn't take into account the character's Speech view, butthat should be easy enought to account for. You could even turn it into a function, to make it easier to use repeatedly:

function Speak(Character *theChar, int y, int text_color, int back_color, String titleText, String message) {
  int TempI = theChar.View;
  theChar.ChangeView(theChar.SpeechView);
  theChar.Animate(theChar.Loop, 3, eRepeat, eNoBlock);
  DisplayTopBar(y, text_color, back_color, titleText, message);
  theChar.ChangeView(TempI);
}

// And then:
Speak(player, 50, 14, 1986, "Roger", "Hello there!");


Also, do you mean 'Dialogs', as in Dialog.Start(), Dialog.SetOption, etc, or 'dialogue', like you're using it in place of Character.Say? That might've caused the confusion in the other thread.
Title: Re: Speech animation
Post by: monkey0506 on Sun 30/09/2007 19:02:54
Ashen, why would you store the character's view, change the view, animate the character, then set it back to what it was in the first place instead of using Character.LockView/Character.UnlockView? If there is then by all means please do tell me...I'm just failing to see why you couldn't do this instead:

function Speak(Character *theChar, int y, int text_color, int back_color, String titleText, String message) {
  if (theChar.SpeechView != 0) {
    theChar.LockView(theChar.SpeechView);
    theChar.Animate(theChar.Loop, 3, eRepeat, eNoBlock);
    DisplayTopBar(y, text_color, back_color, titleText, message);
    theChar.UnlockView();
  }
}

// And then:
Speak(player, 50, 14, 1986, "Roger", "Hello there!");


It's virtually the same, but it doesn't change the character's normal view. Also I've added a check to make sure the character has a valid speech view set.

Edit: Valid point Ashen. ;) Way to keep each other in check eh?
Title: Re: Speech animation
Post by: Ashen on Sun 30/09/2007 22:09:20
Quote
Ashen, why would you store the character's view, change the view, animate the character, then set it back to what it was in the first place instead of using Character.LockView/Character.UnlockView?

Because I was confusing it with something else I was working, on, obviously :)
You're right, in this case Lock/UnlockView makes more sense, although the effect is the same. The theChar.SpeechView != 0 check is a good idea as well - maybe make the theChar.Animate command conditional too, so it doesn't play a 'walking on the spot' animation when they speak.
Title: Re: Speech animation
Post by: .M.M. on Mon 01/10/2007 19:32:42
Thanks,I was using eBlock...
:o :o :o