J
Janar
Guest
Hi
This is my first post in the GMS2 forums and even though I went through forum guidelines and links for new members I'm sorry if there's any formatting issues.
I've been using GMS2 for nearly 6 months and never ran into a problem which I couldn't solve by myself by using google search (which mostly guided me here, GMS2 reddit or YouTube) or tutorials. Sadly I've now run into a simple problem which I can't seem to find a solution for.
What I want to do in GMS2:
Add a Twitter button into my game and add functionality to it so that if it is pressed that would open my Twitter account url in web browser. To do that I'm using a HTML5 function "url_open" which I want to use for my Windows platform game (that itself feels controversial, but according to my searches it should work).
The problems:
Screenshot 1 - before pressing the button
Screenshot 2 - returning to the game after I've clicked on the button with "open_url" function:
Remarks:
Steps to reproduce the problem (in a new blank project):
Any help would be appreciated
This is my first post in the GMS2 forums and even though I went through forum guidelines and links for new members I'm sorry if there's any formatting issues.
I've been using GMS2 for nearly 6 months and never ran into a problem which I couldn't solve by myself by using google search (which mostly guided me here, GMS2 reddit or YouTube) or tutorials. Sadly I've now run into a simple problem which I can't seem to find a solution for.
What I want to do in GMS2:
Add a Twitter button into my game and add functionality to it so that if it is pressed that would open my Twitter account url in web browser. To do that I'm using a HTML5 function "url_open" which I want to use for my Windows platform game (that itself feels controversial, but according to my searches it should work).
The problems:
- The function itself works and if the area is clicked the url is opened in the browser, but if I return to the game the window resolution is slightly smaller that it should be (1864x1049 instead of 1920x1080) and the game should be in full screen, but its not even reaching to the borders of the screen (check the pictures below).
- If the screen is scaled up to 150% (in Windows display settings) the resolution after returning to the game is even a bit smaller (1841x1036).
- What is even stranger is that at some occasions I cannot reproduce the problem, but about 4 out of 5 times i can.
- What should also be noted is that window_set_size() is not capable of resizing the window to match the display size (I've added show_debug_message to the code and it gets stuck in a loop)
- Running the game in Debug mode sometimes opens the game already with the problem which is described in #1
Screenshot 1 - before pressing the button
Screenshot 2 - returning to the game after I've clicked on the button with "open_url" function:
Remarks:
- At first I thought that there was a problem with the screen resolution identifier/changer functionality which I mostly created for the game after PixelatedPope's tutorials, but I tried "open_url" functions in a new blank project and get exactly the same results.
- I'm using point_in_rectangle and mouse_check_button_pressed functions to create the clickable area of the button, because in the end result the text should be clickable in the game (twitter url which displayed as a string and acting like a hyperlink would in a web browser)
Steps to reproduce the problem (in a new blank project):
- Create a new project. Set a room size to 1920x1080
- Go to Game options > Windows > Graphics and tick "Start fullscreen" option
- Create a new object and drag the object into the room
- In the STEP event of the object add the following code:
GML:user_display_width = display_get_width(); user_display_height = display_get_height(); user_window_w = window_get_width(); user_window_h = window_get_height(); if (user_window_w != user_display_width or user_window_h != user_display_height){ if (user_window_w != 0 and user_window_h != 0){ // additional condition, so that it would not try to resize the window if the game window is not active (i've noticed that in that case window gets 0x0 parameters window_set_size(user_display_width, user_display_height); // set the window to size of the display, if for some reason it's not already the same alarm[0] = 1; show_debug_message("User display size: " + string(user_window_w) + "x" + string(user_window_h) + ". Changed window size to: " + string(user_display_width) + "x" + string(user_display_height)); } } // this is not actually used, because the game is still in full screen mode after the resolution changes is_it_fullscreen = window_get_fullscreen(); if (is_it_fullscreen == false){ window_set_fullscreen(true); show_debug_message("Window set to fullscreen"); } // the area of the button and the click event if (point_in_rectangle(mouse_x, mouse_y, 300, 300, 700, 350)){ if(mouse_check_button_pressed(mb_left)){ url_open("https://twitter.com"); } }
- In the DRAW event of the object add the following code:
Code:draw_set_color(c_white); draw_text(0 + 20, 0 + 20, "display_w: " + string(user_display_width)); draw_text(0 + 20, 0 + 40, "display_h: " + string(user_display_height)); draw_text(0 + 20, 0 + 80, "window_w: " + string(user_window_w)); draw_text(0 + 20, 0 + 100, "window_h: " + string(user_window_h)); draw_text(0 + 20, 0 + 140, "is_it_fullscreen: " + string(is_it_fullscreen)); draw_text(300, 280, "Click on white box to go to http://www.twitter.com"); draw_rectangle_color(300, 300, 700, 350, c_white, c_white, c_white, c_white, true);
- Optional: in the Alarm0 event of the object add the following code:
Code:window_center(); // center the window 1 step later than changing the size of the window show_debug_message("Window centered"); alarm[0]=1;
- Run the game and click on the box that has white borders. It should open up the main page of Twitter
- Go back into the game and check if the window size is any different than it was before (check the parameters that are drawn on the left top part of the screen)
Any help would be appreciated