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

Manually resizing the game offsets sprite masking

flyinian

Member
I am using RangerX's pixel perfect tutorial and I've ran into an issue. When the code is active, the masking of my clickable buttons sprites are off centered. Meaning I don't need to be on the button to activate it. The masking offset for each button are in different directions. When the code is not active, the sprite masking is exact.

Code:
//The Create Event Code

application_surface_draw_enable(false);
window_set_fullscreen(true);
global.MonitorW = display_get_width();
global.MonitorH = display_get_height();
global.Xoffset = (global.MonitorW - 640) /2;
global.Yoffset = (global.MonitorH - 360) /2;

if(global.MonitorW >= 1280 && global.MonitorH >= 720)
then
{
    surface_resize(application_surface, 1280, 720)
    global.Xoffset = (global.MonitorW - 1280) /2;
    global.Yoffset = (global.MonitorH - 720) /2;
}
room_goto(RM_mainmenu);


//The Post-Draw code

draw_surface_ext(application_surface, global.Xoffset, global.Yoffset, 1, 1, 0, c_white, 1);
Thank you.
 

flyinian

Member
How are you handling your buttons? What's the code and in what event is the code run?
I was following Gloomy Toad Studios button system tutorial. I have the code that I am using that is used for the button system below.

Tutorial video:

Code:
//Create event

ButtoncenterX = sprite_width / 2;
ButtoncenterY = sprite_height / 2;
image_speed = 0;
clicked = false;

//Draw event

draw_self();
draw_set_font(FNT_buttons);
draw_set_color(Textcolor);
draw_set_halign(fa_center);
draw_set_valign(fa_middle);
draw_text_transformed(x + ButtoncenterX, y + ButtoncenterY, Buttontext, image_xscale, image_yscale, 0);
draw_set_color(c_red);

//Left Pressed

image_index = 1;
clicked = true;

//Left Released

if(clicked)
script_execute(onclickaction);

//Mouse Enter

image_index = 1;
clicked = false;

//Mouse Leave

image_index = 0;
clicked = false;
 
Top