Centre GUI only centres x position.

Started by Kinoko, Wed 25/08/2004 04:30:56

Previous topic - Next topic

Kinoko

I have a bunch of GUIs that I want to sit roughly in the middle of the screen. I know I could manually enter the x and y position to centre them, but I used CentreGUI for ease of use, and I've now realised that it only centres the GUIs x position. Fair enough, I tried manually changing the Y position in the editor - no effect. Is this a bug or is it supposed to work like this? I can get around this by specifying the positions manually, but I was just curious. It doesn't say anything in the manual about only centring horizontally.

Gilbert

#1
I think CentreGUI() applies to both X and Y coordinates (not confirmed), especially when you said the result was the same chaining the Y coordinates in the editor (since its Y coordinate was prabably changed by that function call).

Maybe it justÃ,  seem like it wasn't centred vertically, I think the Y coordinate is set to something like:
(ScreenHeight - GUIHeight)/2

Edit: I checked and can confirm that it centres also the Y coordinate (for V2.62 beta 2 at least).
By "it seem like  it wasn't centred vertically" I meaned that maybe say your GUI was 100x50, but the bottom 20 lines of it was mostly transparent (so it looked like to be 30 in height), so when centred it may seem to be moved 10 pixels up off the centre of screen.

Kinoko

Hmm, well my game is 320x240, and my GUI is 161x200 with no transparency on top or bottom. With just CentreGUI used, it centres it horizontally but it sits exactly at the top of the screen. I'm using AGS 2.61 so perhaps it doesn't work in this version, but you wouldn't think so.

I haven't used any other SetGUIPosition functions or anything anywhere in the game...

strazer

Also, keep in mind that in the game_start function, the screen isn't fully initialized yet.
So CentreGUI might calculate the center from 320x200 instead of 320x240.
Try putting the code in the "Player enters screen (before fadein)" function of your first room.

Kinoko

Ahh, thanks strazer, that was indeed the problem.

SMF spam blocked by CleanTalk