it's this piece of code.. take the position away from mouse position, then the top left corner should be 0 again from any starting position ..
xx=mouse_x-x;
yy=mouse_y-y;
if xx>0 && xx<32*2
&& yy>0 && yy<32
select = xx div 32;
anyway.. I did a rewrite so everything should work fine ..
create
//Same stuff, different location
show=true;
alpha=0;
select=0;
time=20; // time the menu should use to move into place
x-=16; // move the menu position by 16x16
y-=16;
// one could have changed the sprite origins aswell .. but then you would need to fiddle with some more
for(i=1;i<3;i+=1)instance_create(x,y,obj_right_menu_button) // create the buttons right as instance is created. using mouse enter didnt work when the mouse was already inside
step
// this controls image_alpha - max and min is to keep it between 0 and 1
alpha = min(1,max(0,alpha + (show-!show)*1/time))
//image_alpha = 1-alpha; //alpha for menu - when it is gone then this should be clear
with(obj_right_menu_button)image_alpha = other.alpha*1; // give menu buttons the half the alpha. Old Value was 0.5
if show=true{
// get the button number you are over if within menu area
xx=mouse_x-x;
yy=mouse_y-y;
if xx>0 && xx<32*2 // it is 2 in width, however, there is another way to check if on the buttons (see draw event)
&& yy>0 && yy<32
select = xx div 32;
}global right release
if show=true{
show=false; // start hiding buttons
with(obj_right_menu_button){
alarm[1]=other.time; // tell all menu buttons to start alarm 1 which gets rid of them
hspeed=-((image_index*32)/other.time); // and move back up
}
instance_destroy(); //Destroys the menu after being done to allow the instance_number check on obj_create's right click event to reset to 0.
}draw
draw_set_alpha(1)
draw_sprite(spr_select2,0,x + 32*select,y) // draw the selection over the right one
if place_meeting(mouse_x,mouse_y,obj_right_menu_button) // if over tower button
draw_text(x+select*32,y+32,tower_text[select+1]) // then draw tower data
buttons:
create
image_index = instance_number(object_index)-1; //There can clearly only be one of these at a time. Releasing right mouse button, causes this to destroy itself.
image_speed=0;
if image_index < 0 { instance_destroy(); exit; }
alarm[0]=obj_rightclick_button.time; //Changed to new instance. That is all. No further code touched on buttons.
hspeed = (image_index*32)/alarm[0];alarm event 0 can be changed to:
x=xstart+image_index*32
speed=0;