Author Topic: Dialog box and animation questions  (Read 879 times)

Eric

  • Rottwheelers
  • Posts: 1,165
    • I can help with story design
Dialog box and animation questions
« on: 03 May 2014, 20:36 »
...So I've finally gotten together enough art assets that I'm forcing myself to start programming a game. I've got two questions, probably the first of many to come, with apologies if these are obviously simple, and with appreciation for your time and guidance.

Question 1:
I'm trying to move a Sierra-style portrait system to the bottom of the screen, as I've created backgrounds with a lot of foot room, and not as much head room (so heads of characters were constantly blocked by the dialog box). I've successfully done so, using Crimson Wizard's recent addition to 3.3.0, Speech.CustomPortraitPlacement (thank you, CW!).

The portrait's now in the right place, but the accompanying dialog box still aligns to the top of the portrait. Since it's at the bottom of the screen, I'd like the text box to align with the baseline of the portrait (which I've set to be 15 pixels from the bottom of the screen).

Is that possible?

Question 2:
Now that the heads are visible, I am curious as to whether it would be possible for there to be an additional talking animation to be played for the character's non-portrait, walking-around sprite. I'll be lip-syncing the portrait (hopefully with voice tracks), but the sprite can just have a simple loop of three mouth movement frames.

Is that possible?

Thanks again!

Gurok

  • Rottwheelers
  • Posts: 1,793
  • When life hands you lemons, combine them with the mop
    • I can help with AGS tutoring
    • Best Innovation Award Winner 2016, for improving and extending the AGS scripting language
    • I can help with proof reading
    • I can help with scripting
    • Gurok worked on a game that won an AGS Award!
    •  
    • Gurok worked on a game that was nominated for an AGS Award!
Re: Dialog box and animation questions
« Reply #1 on: 04 May 2014, 02:11 »
I'm not sure about question 1. To move my text GUIs down a few pixels, I used top borders that were padded with about 10 pixels of transparency. Actually moving the boxes around might be possible, but I haven't discovered how.

I think I can help you with question 2 though. This is roughly how I did it:

Code: Adventure Game Studio
  1. // In header (e.g. Character.ash)
  2. #define Character_ANIMATE_DELAY  4
  3.  
  4. bool  Character_Initialised;
  5. int   Character_Chat[ ];
  6. bool  Character_Spoken[ ];
  7.  
  8. import function SetChatView(this Character *, int chat);
  9.  
  10. // In module (e.g. Character.asc)
  11. function InitialiseCharacter()
  12. {
  13.         if(!Character_Initialised)
  14.         {
  15.                 Character_Initialised = true;
  16.                 Character_Chat = new int[Game.CharacterCount];
  17.                 Character_Spoken = new bool[Game.CharacterCount];
  18.         }
  19.  
  20.         return;
  21. }
  22.  
  23. function SetChatView(this Character *, int chat)
  24. {
  25.         InitialiseCharacter();
  26.         Character_Chat[this.ID] = chat;
  27.  
  28.         return;
  29. }
  30.  
  31. function repeatedly_execute_always()
  32. {
  33.         int index;
  34.         bool speaking;
  35.  
  36.         InitialiseCharacter();
  37.         index = Game.CharacterCount;
  38.         while(index > 0)
  39.         {
  40.                 index--;
  41.                 if(character[index].Room == player.Room)
  42.                 {
  43.                         speaking = character[index].Speaking && character[index].SpeakingFrame > 0;
  44.                         if(speaking)
  45.                         {
  46.                                 if(!Character_Spoken[index])
  47.                                 {
  48.                                         character[index].LockView(Character_Chat[index]);
  49.                                         character[index].Animate(character[index].Loop, Character_ANIMATE_DELAY, eRepeat, eNoBlock);
  50.                                 }
  51.                         }
  52.                         else
  53.                                 if(Character_Spoken[index])
  54.                                         character[index].UnlockView();
  55.                         Character_Spoken[index] = speaking;
  56.                 }
  57.         }
  58.  
  59.         return;
  60. }
  61.  

I tend to extend the built-in objects where I can. In your game_start(), you can just call something like this:

Code: Adventure Game Studio
  1. cFred.SetChatView(FREDCHAT);

If you have 2-3 frames of chat animation for your walking sprites, this will work really well. It starts when the portrait starts talking and stops when the portrait stops, so if you have pauses at the end of your dialogue, the characters won't go on chatting while the portrait is paused. Hope this helps!

Oh, I might add. I tried this, but found it visually confusing in the end. It's odd, but when both the portrait and the regular view are animated at once, your eye is drawn to two places, one of them not where the text is.
« Last Edit: 04 May 2014, 02:17 by Gurok »

Eric

  • Rottwheelers
  • Posts: 1,165
    • I can help with story design
Re: Dialog box and animation questions
« Reply #2 on: 04 May 2014, 03:54 »
That works brilliantly, Gurok! Thank you!

Quote from: Gurok
found it visually confusing in the end. It's odd, but when both the portrait and the regular view are animated at once, your eye is drawn to two places, one of them not where the text is.

I suppose I'll find this out in letting others test, eventually, but one of my motivations is that my sprites are hi-res and generally pretty big on the screen, so it doesn't look right to me for the character to sit idle. But this is a good thing to keep in mind. Thank you!