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

HTML5 Scale in browser

Hi there,

I have an question. Sorry for my bad English, but I will try to explain my problem. I'm scaling my game with this code:
if ((prev_browser_width != browser_width) || (prev_browser_height != browser_height))
{
var bw, bh, rw, rh, nw, nh, nx, ny, ra;
bw = browser_width;
bh = browser_height;
rw = view_wport[0];
rh = view_hport[0];
nx = 0 // new x
ny = 0 // new y
// nw en nh zijn 'new width' en 'new height'

if ((bw / rw) > (bh / rh))
{
nh = bh
nw = rw * (bh / rh)
nx = (bw / 2) - (nw / 2)
}else{
nw = bw
nh = rh * (bw / rw)
ny = (bh / 2) - (nh / 2)
}


surface_resize(application_surface, nw, nh);
view_set_wport(0,nw)
view_set_hport(0,nh)
view_set_xport(0,nx)
view_set_yport(0,ny)

window_set_size(nw, nh)
window_set_position(nx, ny)



prev_browser_width = browser_width
prev_browser_height = browser_height
}

Now the game window is scaling the way I want, but when i'm scaling my game down, sometimes my buttons didn't work. Is it possible to fix this problem? I you want, you can test it here: https://meesterdennis.nl/temp/serieren2.html

I hope someone can help me.

Greets,
Dennis van Duin

Ps: As you can see, I want to scale my game bij de width ore the height of the browser. You always have to so everyting, but it is okay to see some empty space near te game on the left and right, ore above en below the game.
 
I create the buttons with this code:
Alarm[0]:
/// @description Insert description here
// You can write your code in this editor
show_debug_message("Start alarm1 game 1" +string(antwoord))
// Maken van de buttons (anders moet je 4 nieuwe objecten aanmaken en nu maar 1)
list = ds_list_create()
ds_list_add(list,img1)
ds_list_add(list,img2)
ds_list_add(list,img3)
ds_list_add(list,img4)
ds_list_shuffle(list)
//ds_list_sort(list,1)
for (i=0; i<4; i+=1)
{
k = instance_create_depth((room_width/2)-400+(250*i),(room_height/2)+100,0,obj_antwoord_game1)
k.img = ds_list_find_value(list,i)
show_debug_message("Create button game 1")
}
ds_list_destroy(list)

The buttons stopped working when I resize the window...

Thanks for replying.

Greets,
Dennis van Duin
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
That doesn't really help... How are you detecting the button presses? Are you using virtual keys? Are you using the GUI layer?
 
Hi there,

I'm using the normal draw event to draw the button on his own X and Y en I'm drawing an string on hins X and Y.

I do not use the virtual keys for pressing the button, I use the left_released event.

Greets,
Dennis
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
I do not use the virtual keys for pressing the button, I use the left_released event.
Thank you. I've just done a test and you are right, something isn't right with the HTML5 and mouse events when scaled. I'll go ahead and file a bug using my test project. Thanks for finding this and it'll be fixed ASAP.
 
Thank you. I've just done a test and you are right, something isn't right with the HTML5 and mouse events when scaled. I'll go ahead and file a bug using my test project. Thanks for finding this and it'll be fixed ASAP.
Ah, I guess this is one of those situations where, if you don't log a bug then it won't get fixed... this has been broken since the first iteration of the HTML5 module in GMS 1, when scaling the canvas, the mouse co-ordinates don't adjust accordingly. There is a work around though.

If I'm not mistaken, before Mantis was updated, there was a bug filed for this, last time I checked was around 8 months ago, so I can't remember exactly if it was this issue. This has been fixed and should appear in the next update from what I've read on the forum, it's truly satisfying knowing we have @YellowAfterlife cleaning up the overdue bugs on the HTML5 module...
 
Top