Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Lewis on Tue 05/11/2013 07:46:27

Title: Set GUI position in relation to character
Post by: Lewis on Tue 05/11/2013 07:46:27
Hiya.

So imagine if you could have a super-swish GUI pop up in relation to the position of a character. How would one go about doing this?

It seems to me that the issue is GUI positions being based on screen coordinates whereas character positions are based on room coordinates. So

Code (ags) Select
gGUI1.X=cCHAR1.x+15;
gGUI1.Y=cCHAR1.y-15;
gGUI1.Visible=true;


doesn't manage to display the GUI at all.

Any help appreciated. Ta!
Title: Re: Set GUI position in relation to character
Post by: Crimson Wizard on Tue 05/11/2013 07:52:35
Whenever you want to convert room coordinates to screen coordinates, use Viewport:

Code (ags) Select

gGUI1.X = cCHAR1.x - GetViewportX() + 15;
gGUI1.Y = cCHAR1.y - GetViewportY() - 15;
Title: Re: Set GUI position in relation to character
Post by: Andail on Tue 05/11/2013 08:16:30
It seems strange that it won't display at all. How is it triggered? Is it supposed to follow the character around, using repeatedly_execute () ?
Viewport is only a position issue in scrolling rooms, it shouldn't prevent it from displaying completely.
Title: Re: Set GUI position in relation to character
Post by: Crimson Wizard on Tue 05/11/2013 08:47:22
Quote from: Andail on Tue 05/11/2013 08:16:30
It seems strange that it won't display at all.
Right... maybe the GUI type is incompatible with this task, like "popup when mouse is at Y"?
Title: Re: Set GUI position in relation to character
Post by: Lewis on Tue 05/11/2013 09:41:53
I could get the GUI to pop up when I specified just room coordinates, but when character coordinates were specified it didn't appear anywhere.

At least, it didn't *seem* to. There's a slight chance I was a massive idiot and it was displaying off-screen, as it's a scrolling room.

I'll check this when I get back from the office later on. Thanks folks!