• 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!

Legacy GM (SOLVED) Trying to Draw cursor on the Draw GUI event

Catfish

Member
Alright, I'll cut to the chase, because my issue is a heckin weird one.

So, I have a camera code where I can zoom in and out, move the view around with arrow keys, etc. Works great.
I'm also trying to add a custom cursor (with multiple frames, so I can't just set the cursor to a sprite) that won't resize when you zoom the camera. So my last option is to draw it in Draw GUI.
However, getting the cursor to follow the mouse AND have it work well with the Draw GUI event is NOT happening. It just kinda... either slides around, or just doesn't appear on-screen at all. Here's my code for the step event of my camera object:

///Move view
var view_midx, view_midy;
view_midx = view_xview[0] + (view_wview[0]/2);
view_midy = view_yview[0] + (view_hview[0]/2);
if (keyboard_check(ord("A")) + keyboard_check(vk_left)) - (keyboard_check(ord("D")) + keyboard_check(vk_right)) > 0{
view_xview[0] -= round(view_wview*0.005);
}
if (keyboard_check(ord("A")) + keyboard_check(vk_left)) - (keyboard_check(ord("D")) + keyboard_check(vk_right)) < 0{
view_xview[0] += round(view_wview*0.005);
}
if (keyboard_check(ord("W")) + keyboard_check(vk_up)) - (keyboard_check(ord("S")) + keyboard_check(vk_down)) > 0{
view_yview[0] -= round(view_wview*0.005);
}
if (keyboard_check(ord("W")) + keyboard_check(vk_up)) - (keyboard_check(ord("S")) + keyboard_check(vk_down)) < 0{
view_yview[0] += round(view_wview*0.005);
}
if mouse_wheel_up() && view_wview > 320{
view_wview[0] -= 128;
view_xview[0] += 64;
view_hview[0] -= 72;
view_yview[0] += 36;
}
if mouse_wheel_down() && view_wview < 1280{
view_wview[0] += 128;
view_xview[0] -= 64;
view_hview[0] += 72;
view_yview[0] -= 36;
}
view_xview[0] = clamp(view_xview[0],0,room_width-view_wview[0]);
view_yview[0] = clamp(view_yview[0],0,room_height-view_hview[0]);

Does anyone what code might make this work properly for Draw GUI? Thank you!
 
Last edited:
  • Like
Reactions: Mut

Rob

Member
To draw a Sprite in the GUI layer:

Code:
dx = device_mouse_x_to_gui(0);
dy = device_mouse_y_to_gui(0);

draw_sprite(spr_cursor, cursor_index, dx, dy);
 
Last edited:

Catfish

Member
To draw a Sprite in the GUI layer:

Code:
dx = device_mouse_x_to_gui(0);
dy = device_mouse_y_to_gui(0);

draw_sprite(spr_cursor. cursor_imdex, dx, dy);
Oh my god it worked like a charm. Exactly what I was looking for, thank you!!
 
  • Like
Reactions: Mut
Top