Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Dave Gilbert on Wed 30/08/2017 17:55:26

Title: [Solved] SayBackground Y position
Post by: Dave Gilbert on Wed 30/08/2017 17:55:26
Hi hive mind.

I have a room in my game where a bunch of characters are sitting on subway seats. You can select which character goes with you on a mission by clicking on them. When you click on them, they play an animation where they stand up. So far so straightforward.

I added some background banter conversation between the characters, using the SayBackground command. When the characters are seated, it displays normally:

(http://www.unavowed-game.com/temp/vickisit.png)

But after I click on a character and they stand up, the text is always displayed at the "seated" Y position, covering the talking character:

(http://www.unavowed-game.com/temp/vickistand.png)

How does SayBackground determine the Y position? Can it be changed or adjusted in any way? I'm sure the solution to this is something obvious that I am missing, but any light shedding is appreciated!

Thanks,

-Dave

edit: To clarify, I am not clicking on the character while the text is being displayed. The character is already standing when the SayBackground command is called.
Title: Re: SayBackground Y position
Post by: Kitty Trouble on Wed 30/08/2017 18:40:26
After experimenting with this I have learned the following about Y position:

1) It is based on the height of the 1st frame of the view
2) It will re-calculate when you switch views, but not during animations.

Hope that helps!
Title: Re: SayBackground Y position
Post by: Dave Gilbert on Wed 30/08/2017 18:51:09
Ahhh. I adjusted the height of the 1st frame to match but now the text is way too high when they are sitting. :)

(http://www.unavowed-game.com/temp/elisit.png)

Is there a clever way around this or am I going to have to switch in and out of views?

Either way, I will fiddle. Thanks!
Title: Re: SayBackground Y position
Post by: Kitty Trouble on Wed 30/08/2017 19:19:09
I'm not experienced with AGS but it doesn't seem like you can do it without switching views, unless you want to go the route of having invisible characters and write a custom function.
Title: Re: SayBackground Y position
Post by: Kitty Trouble on Wed 30/08/2017 20:05:35
Code (ags) Select
  ViewFrame *currentFrame = Game.GetViewFrame(cEgo.View, cEgo.Loop, cEgo.Frame);
  ViewFrame *firstFrame = Game.GetViewFrame(cEgo.View, cEgo.Loop, 0);
  firstFrame.Graphic = currentFrame.Graphic;
  cEgo.SayBackground("Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello ");


Here are a few lines of script that could solve this problem, of course you'd need to re-set the first frame before you started animating again.
Title: Re: SayBackground Y position
Post by: Monsieur OUXX on Thu 31/08/2017 08:49:34
Another workaround : create 4 dummy invisible characters that you place above each real character, and adjust those characters' Y position as needed.
Less classy than Morgan's solution, but less risk to mix up the frames and have a faulty 1st frame.

Title: Re: SayBackground Y position
Post by: Snarky on Thu 31/08/2017 14:15:29
Yeah, I was gonna say: overwriting frames in the loop seems like something that has a high risk of causing weird bugs elsewhere in your game, unless you're very careful to encapsulate the code and always restore the frame properly afterwards.
Title: Re: SayBackground Y position
Post by: Kitty Trouble on Thu 31/08/2017 14:33:12
It was just an idea, as I mentioned before having invisible "dummy" characters and creating a new view would both also do the trick, just depends on how you wanna go about it.
Title: Re: SayBackground Y position
Post by: Dave Gilbert on Fri 01/09/2017 15:23:41
Huh. Some neat ideas! Changing the first frame of the loop shouldn't effect things TO much, since visually the frame won't change. Thanks for the tip. I'll give it a whirl now.
Title: Re: SayBackground Y position
Post by: Dave Gilbert on Fri 01/09/2017 15:41:17
Hooray it works!

https://www.youtube.com/watch?v=u2tcZG3bU8Q