Let's assume the origin point for the sprite is in the upper left corner. You can then use the instance's x and y coords to refer to that location. Next you measure the distance of upper left and lower right corner of each button from the sprite's upper left corner, and set them up as variables in create step. For example, for the first button you might set up something like this (numbers are for reference only):
Code:
// CREATE EVENT
Button1_X1 = 20; // upper left x
Button1_Y1 = 150; // upper left y
Button1_X2 = 60; // lower right x
Button1_Y2 = 170; // lower right y
You can now calculate the current button position by adding x and y, respectively, to those variables. To check whether current mouse position is within the button's rectangle, you can use
point_in_rectangle which is a command for that exact purpose:
Code:
// STEP EVENT
if(mouse_check_button_pressed(mb_left){
if(point_in_rectangle(mouse_x, mouse_y, Button1_X1 + x, Button1_Y1 + y, Button1_X2 + x, Button1_Y1 + y)){
// Action for the button press
}
// Handle the rest of the button in same manner here
}
Alternatively, you
could set up the buttons as separate objects and make them follow their parent window, but you don't gain much there expect not having to measure button positions.