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

Windows Sometimes when the game starts in window mode, one side of the screen is not clickable

Owly

Member
Hey, I'm encountering a funny bug, sometimes when the game starts in window mode, one side of the screen is unclickable (in fact I can't go there with the mouse, it leaves that part of the window and goes outside of it to Windows), and the only way to solve this is to go to the options menu, and turn off window mode (if I then turn it back on, it works fine).

I'm running my program on windows 10, resolution is 1920x1080. Do you know what may cause this or do you need to see the code for this?
 

Japster

Member
@Owly - I get the same thing in my game, TetraLogical - sometimes it starts in Windowed mode, doesn't seem to flag it as such, and only works properly when I re-select Windowed mode - exact same issue as yourself, actually. My application is in 1920x1080, but on a 2560x1440 monitor, in the higher resolution - full-screen is fine, but Windowed mode sometimes does this to me...

What I've realised might work, (and I'll test on mine), is maybe re-applying what the game 'thinks' is the current mode, after a small part-second delay.

I'm going to give that a try - after all, if I get the issue, and luckily my Fullscreen switch button is in the top-left of my app, so is navigable even despite the cursor disappearing, then manually clicking that button once, fixes it. It's a fudge, but if code emulating that fixes it, I'm happy!
 

Owly

Member
Hey, thanks for replying. I think you've described the problem accurately, " sometimes it starts in Windowed mode, doesn't seem to flag it as such..." Yeah, I suppose something with the flagging went wrong. I went over my code after posting here and found that my code dealing with resolution / display was a bit funny. Sometimes it sent two or multiple instructions with regards to setting Window Mode on or off (or with regards to setting the resolution to 1920x1080 or something else). So I tweaked it a bit making sure only one instruction was sent when the code was read and that fixed the problem for me (at least it has never repeated since lol).
 

Japster

Member
No worries @Owly ! - Glad it helped! :D

Ps - I had a nightmare creating a draggable object that let you smoothly, in real time with no white screen, drag a GMS game window around, over the last day or so, but I'm REALLY pleased with it now.... :)

If it helps on your (or anyone else's) project, I'll drop it here?

It's fairly straightforward, and will allow smooth dragging of the game's window position, using the mouse, but will clamp / not allow dragging outside of the host resolution, so it's easy for players to position the game window anywhere that they like, VERY quickly, and looks professional (ie. I have my game in a borderless window) - Using this object as a 'ghost / hidden until rolled over' hot spot for dragging it, they can whack the game in a corner even, in a split second if they like, without micro-adjusting it.... :)

All the best!


Den.
 
Last edited:

Japster

Member
Will do! - it's simple logic, but still caused me a couple of headaches getting it right - I'm happy with the end result - I took a small GIF anim of it, but the quality and rate of the GIF was awful... :)

Will upload it tomorrow, or put the code snippets for the events in here, once I've cleaned up some un-needed code and some test 'magic numbers' from the object... ;)

All the best!
 

Japster

Member
@Owly Okay! - uploaded to my Dropbox as I cannot share Zips here...

Even while dragging this game window around, I have a scrolling/animated background, and it all still runs super smoothly while dragging, so I'm happy... :) :-

Download Object

My example just uses a simple 64x64 pixel sprite (although for aesthetic reasons I've now scaled the object to 0.66 vertically in the example shown), either plain white, or a gradient, and set the blend in the object - attached below, with an example:-

252b7f73-714e-403e-824f-a842cc4d49a1.png

Grab_Capture.png

If you prefer to create your own object, here's the events code:-

/// @description Set Up Variables

xx = 0;
yy = 0;

Grabbed = false;
MinAlpha = 0.4;
MaxAlpha = 0.8;
FadeInRate = 0.03;
FadeOutRate = 0.06;
DragMessage = "";

image_blend = c_black;

(EDIT - Note! - Changed this to END STEP - This is REALLY important, as I found that placing the code in BEGIN STEP, or STEP, causes an issue where if the window is moved quickly, thereby changing the in-game mouse_x & mouse_y, it causes a jittering effect (due to the window constantly resetting between the two positions - ie. Moving the window relative to the perceived mouse movement, but with GMS2 adjusting mouse_x and mouse_y accordingly, causing a rapid (every other frame) swap back and forth between the 2 on-screen locations)...
/// @description Move Window If Grabbing...

if (Grabbed)
{
xx = window_get_x() - (StartMouse_x-mouse_x);
yy = window_get_y() - (StartMouse_y-mouse_y);

var wx = clamp(xx,0,display_get_width()-window_get_width());
var wy = clamp(yy,0,display_get_height()-window_get_height());

window_set_position(wx,wy);
}

//
// Code below is only needed if fading bar in - delete if not required!
//

if ((mouse_y <= self.sprite_height) || Grabbed)
{
DragMessage = "Click and HOLD to move / drag window!";
image_alpha = min(MaxAlpha,image_alpha + FadeInRate); // smoothly fade in bar....
}
else
{
DragMessage = "";
image_alpha = max(MinAlpha,image_alpha - FadeOutRate); // smoothly fade in bar....
}

<Draw Event> Just add a <BLANK> 'DRAW' EVENT as we're drawing at GUI level...

/// @description Insert description here

draw_self();

draw_set_font(Tiles);
draw_set_halign(fa_center);
draw_set_valign(fa_middle);

draw_text_transformed_color(x,y,DragMessage,.6,.6,0,c_white,c_white,c_white,c_white,1);
/// @description Grab BAR

if (mouse_y <= self.sprite_height)
{
Grabbed = true;
StartMouse_x = mouse_x;
StartMouse_y = mouse_y;

xx = window_get_x() - StartMouse_x;
yy = window_get_y() - StartMouse_y;
}
/// @description Drag Ended

Grabbed = false;

PS- I'm not precious! - if any veteran GMS2 coders want to improve / optimise this hacky code, then please, feel free!... :D
 
Last edited:

Owly

Member
Thanks, I'll experiment with it, and thanks for the code too, very elegant and I'm sure there's something to learn from it! :)
 

Japster

Member
No worries! - I also removed (from the post and my own code) a couple of (un-needed/potentially troublesome) "image_yscale" bits from the vertical position calcs - They're no longer needed, as I switched to the simpler "sprite_height", and not "sprite_get_height * image_yscale"... :)

If in doubt, just grab the code for "Drag Start" and "End Step" events from the edited post above, and re-paste it into the object in your project... :)

All the best! - Would be interested to hear how you get on with it if it's any use to you.... :)

PS - The code *was* nicely indented, etc, but I think I lost it pasting it in using spoiler tags... :)
 
Last edited:
Top