How to create "The Sims" style gui?

Started by , Wed 27/09/2006 18:45:32

Previous topic - Next topic

Redbeard

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

Khris

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);

Redbeard

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'

Khris

Sorry, my bad, put "int" before the h:
Ã,  int h=player...

Redbeard

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);

Khris

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);

SMF spam blocked by CleanTalk