Windows When an instance is created, how do I make it so that it is created in the center of my viewport?

sma

Member
I have a viewport with the size of 1024x768, and an object with this code.


GML:
//CREATE EVENT
menu_x = x;
menu_y = y;
button_h = 60;



// buttons
button[0] = "Stats";
button[1] = "Inventory";
button[2] = "Close";
buttons = array_length_1d(button);

menu_index = 0;
last_selected = 0;


//this is what should define its starting position
x = camera_get_view_x(view_camera[0])+500   
y = camera_get_view_y(view_camera[0])+500
I don't understand why this doesn't work, as when the instance is created, it's position is not in the center of the viewport
 
If you want the center of 1024x768, shouldn't that be (512, 384)?

Code:
//this is what should define its starting position
x = camera_get_view_x(view_camera[0])+512  
y = camera_get_view_y(view_camera[0])+384
 
Top