• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker window_set_cursor only works with last instance

Gamebot

Member
I had thought that window_set_cursor was like a global which changes whenever you tell it too. It does for the most part except it only seems to change with the last instance. I tried two, then three, and four instances with each only the last instance will run the window_set_cursor code.

Oddly enough though all other relevant code before and after the changes happen. See here where I "divided" my box into 9 sections called setsize (for changing sizes and dragging). Sorry if it doesn't come out clear this time.


nodes box all.png

The left section, with three instances shows that the over and drag code get executed by the black box border however only the last instance changes to the drag hand. The right two single boxes show that my setsize or area where the mouse hits is working but not the cursor code except again the last instance. Here's the main code im currently using:

scr_get_handle();
Code:
var pix = 4;

// if we are over any instance of obj_box exit so we don't change size accidentally when mouse is over both.
if (obj_box.mouse_over = true)
{setsize = 0; window_set_cursor(cr_arrow);}

// Over top left corner. Movement Hor left and Vert up (-x , -y)
else if (point_in_rectangle(mouse_x, mouse_y, x - pix, y - pix, x + pix, y + pix))      
{setsize = 1; window_set_cursor(cr_size_nwse);}

// Over top but not in corners. Movemnent Vert up only (x , -y)
else if (point_in_rectangle(mouse_x, mouse_y, x + pix, y - pix, x + wid - pix, y + pix))      
{setsize = 2; window_set_cursor(cr_size_ns);}

// Top right corner. Movement Vert up and Hor right. (+x , -y)
else if (point_in_rectangle(mouse_x, mouse_y, x + wid - pix, y - pix, x + wid + pix, y + pix))
{setsize = 3; window_set_cursor(cr_size_nesw);}

// Left of box not in corners. Movement Hor left only. (-x , y)
else if (point_in_rectangle(mouse_x, mouse_y, x - pix, y + pix, x + pix, y + hei - pix))
{setsize = 4; window_set_cursor(cr_size_we);}

// Right of box not in corners. Movement Hor Right only. (+x , y)
else if (point_in_rectangle(mouse_x, mouse_y, x + wid - pix, y + pix, x + wid + pix, y + hei - pix))
{setsize = 5; window_set_cursor(cr_size_we);}

// Left bottom corner. Movement Hor left and vert down. (-x , +y)
else if (point_in_rectangle(mouse_x, mouse_y, x - pix, y + hei - pix, x + pix, y + hei + pix))
{setsize = 6; window_set_cursor(cr_size_nesw);}

// Bottom of box. Movement vert down only. (x , +y)
else if (point_in_rectangle(mouse_x, mouse_y, x + pix, y + hei - pix, x + wid - pix, y + hei + pix))
{setsize = 7; window_set_cursor(cr_size_ns);}

// Bottom right corner. Movement Hor right and vert down. (+x , +y)
else if (point_in_rectangle(mouse_x, mouse_y, x + wid - pix, y + hei - pix, x + wid + pix, y + hei + pix))
{setsize = 8; window_set_cursor(cr_size_nwse);}

else {setsize = 0; window_set_cursor(cr_arrow);}
Also I did try changinging all steps and draw events just to see if it would make a difference. None. Any thoughts appreciated.
 
Last edited:

Gamebot

Member
[ UPDATE ]

It seems the last else statement is the issue. If I take that line of code out...everything seems to work fine except the fact that the cursor never changes back. Also I tried putting the window_set_cursor into an alarm with one step difference (thinking about how window_center works) that didn't help either. Back to the drawing board I guess.

I'm almost wondering if it has something to do with changing specifically to the arrow and vicde versa. I did try to use default also but no luck.
 
Top