Windows Question about Screen Resolutions.

R

Ratatosque

Guest
Hello there,

recently im trying to implement an option to change the screen resolutions. Im using a pretty good tutorial by slasher x games. So far the screen resizes properly with different resolutions and black boxes are created to keep the aspect ratio. My problem is that fixed objects like buttons in the menu dont accompany the screen changes. Everytime i change the resolution the buttons get offset and end up outside of the menu. Any idea why this may be the case or how to properly tie the button-objects to the GUI elements?

Thanks a lot!
 
R

Ratatosque

Guest
maybe i can explain a bit better.

my obj_Control_Settings uses the following code to create the buttons
Code:
//Create Event
menu_center_x=global.displayWidth/2;
menu_center_y=global.displayHeight/2;

//(the global.displayWidth and Height are set when you click the button for the appropriate resolution)

//Alarm Event (after create animation is over)
instance_create(menu_center_x-249,menu_center_y-226,obj_Button_Video);
    instance_create(menu_center_x-84,menu_center_y-226,obj_Button_Audio);
    instance_create(menu_center_x+81,menu_center_y-226,obj_Button_Control);
    instance_create(menu_center_x+102,menu_center_y+147,obj_Button_Accept_OL);
    instance_create(menu_center_x+200,menu_center_y+147,obj_Button_Cancel_OL);
So the menu spawns in the center and the the buttons are created at a position realtive to the spawn location of the menu.
However when i change the resolution the buttons dont move accordingly but stay offset at awkward positions. On higher
resolutions i even have to quit the game because i cant find the "real" position of the buttons because their sprites are drawn
in a draw_GUI event. They are there somewhere, not in the menu, but even their drawn location doesnt mean they are really there,
its really strange.
 
L

Luck

Guest
Maybe you didn't post the full code but would you not need to destroy the original buttons and then redraw them after a resolution change? As is the code you provided doesn't do anything to update the button's positions once drawn. Setting them to "x+200" doesn't mean they will dynamically change with x, it means they will set their position based off the x value at the time the code runs.
 
R

Ratatosque

Guest
Maybe you didn't post the full code but would you not need to destroy the original buttons and then redraw them after a resolution change? As is the code you provided doesn't do anything to update the button's positions once drawn. Setting them to "x+200" doesn't mean they will dynamically change with x, it means they will set their position based off the x value at the time the code runs.
yeah that seems plausible. but it seems not so elegant. i thought maybe someone had some kind of simple standard solution to lock objects to ui positions.
 
Top