Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: on Wed 27/09/2006 18:45:32

Title: How to create "The Sims" style gui?
Post by: on Wed 27/09/2006 18:45:32
I was wondering if it would be possible to create a gui that would apear right next to your player no matter what his location was. For example, lets say if you left click on your player a few buttons would appear over his head to allow a choice of interactions. I had to swith to a different gui design because this was a big hassle trying to code such a feature since I dont know how to offset the "animation scaling". In addition, is it possible to compare "gui.centre" to the center location of the player? Thanks.

Redbeard
Title: Re: How to create "The Sims" style gui?
Post by: Khris on Wed 27/09/2006 20:33:04
GUI.Centre() moves the GUI back to the center of the screen.

What you need is a bit of code in the repeatedly_execute function of the global script:
Ã,  GUI*g=NameOfYourGUI;Ã,  // change accordingly
Ã,  h=player.Scaling*[height]/100+5;Ã,  // replace [height] with char sprite height, 5 is spacing
Ã,  gNameOfGUI.SetPosition(player.x-GetViewPortX()-g.Width/2, player.y-h-g.Height);
Title: Re: How to create "The Sims" style gui?
Post by: on Wed 27/09/2006 21:15:38
Thanks for the quick reply, however I ran into a little snag:

GUI*g=gTest;Ã, 
h=player.Scaling*[98]/100+5;Ã, 
gTest.SetPosition(player.x-GetViewPortX()-g.Width/2, player.y-h-g.Height);

After I put this code into the rep_ex section of the global, I get this error: Undefined token 'h'
Title: Re: How to create "The Sims" style gui?
Post by: Khris on Wed 27/09/2006 22:40:31
Sorry, my bad, put "int" before the h:
Ã,  int h=player...
Title: Re: How to create "The Sims" style gui?
Post by: on Wed 27/09/2006 22:49:18
Ok now I get another error: Parse error in expr near '['

GUI*g=gTest;Ã, 
int h=player.Scaling*[98]/100+5;Ã, 
gTest.SetPosition(player.x-GetViewPortX()-g.Width/2, player.y-h-g.Height);
Title: Re: How to create "The Sims" style gui?
Post by: Khris on Wed 27/09/2006 23:54:44
Ok, here's the whole thing, I hope this'll work now:

Ã,  GUI*g=gTest;Ã, 
Ã,  h=player.Scaling*98/100+5;Ã,  // no []
Ã,  gTest.SetPosition(player.x-GetViewPortX()-g.Width/2, player.y-GetViewPortY()-h-g.Height);