• 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!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

HTML5 View not functioning properly in HTML5

I just bought the HTML5 license in the sale and wanted to get my minesweeper clone working in a browser. The only problem I'm having is that the camera does not seem to work properly and some GUI element don't draw at all. The view appears to be much larger than it should be, it is showing the background colour which should never be visible. The GUI is the proper size but the 9 slice border sprite has disappeared even though it is being drawn in the same event as the other GUI elements. When I check the camera and GUI size attributes when the game is running they show that they are the correct values.

Windows desktop version vs HTML5 version in Firefox

working.png not_working.png

Camera object create event code:
GML:
view_enabled = true;

view_visible[view] = true;


var scale = game.scale;

//desktop view is dependant on the current minefield dimensions

if(os_browser == browser_not_a_browser){

    viewWidth = (field.width*tileSize + borderSize*2);

    viewHeight = (field.height*tileSize + borderSize + borderTopSize);

    camera_set_view_size(view, viewWidth, viewHeight);

    camera_set_view_pos(view, -borderSize, -borderTopSize);

}

//HTML view is dependant on the max minefield dimensions (30x16)

else{

    viewWidth = (30*tileSize + borderSize*2);

    viewHeight = (16*tileSize + borderSize + borderTopSize);

    camera_set_view_size(view, viewWidth, viewHeight);

    camera_set_view_pos(view, -borderSize-(15*tileSize), -borderTopSize);

}

window_set_size(viewWidth*scale, viewHeight*scale);

display_set_gui_maximize(scale, scale);

display_set_gui_size(viewWidth, viewHeight);

surface_resize(application_surface, viewWidth, viewHeight);
 
Found a kind of work around solution.

My game has multiple themes/skins that can be changed kind of like minecraft texture packs. A themes sprite is drawn to a surface, then new sprites are created from different parts of the surface then the surface is destroyed at the end. I think the problem with the border not drawing might be that you can't create a nine slice sprite using sprite_nineslice_create() and sprite_set_nineslice() in HTML. It could also be that I was having one object draw a sprite that was created by another like: draw_sprite(game.spr_border, 0, 0, 0). Instead of loading the sprite this way I just created the individual sprites for each themes tiles, faces, numbers, and border and switch between which sprites are being used.

I still haven't managed to fix the view but my solution was just to have the tiles drawn to the GUI layer instead.

edit: also if anyone is having trouble with the incorrect sprite being drawn make sure you clean your project before running using the icon next to the run and stop buttons.
 
Top