1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

GMS 2 prevent mouse outside GUI area

Discussion in 'Programming' started by PandaPenguin, Aug 24, 2017.

  1. PandaPenguin

    PandaPenguin Guest

    Im not sure if it's just me doing it plain wrong or if there is just no simple way for this problem:

    you have a 16:9 game and want it to run in fullscreen
    works fine on all 16:9 displays but has black bars on any other aspecr ratio display (when you want to keep aspect ratio and not distort your graphics)

    these black bars count as game area too so any stuff that happens on GUI layer gets involved
    anything drawn on GUI layer can be drawn there unintentionally, like a sprite that follows the mouse (custom cursor, crosshairs etc)
    clicks that happen on black bars get detected too

    solution 1:
    use clamp() to limit any mouse_x/y coordinate uses to the GUI area only (with conversion from world coordinates to gui coordinates first)
    use same GUI area limitation for all mouse clicks to ensure they happened "inside" the actual game area

    solution 2,3,4,5,6?:
    dynamically resize application area, gui layer, camera port to adapt to the different aspect ratios?
    how would you manage the dynamic scaling so that you dont accidentally "see" more of the world on different ratios than intended?
    keep the height and only adjust the width to fit the displays aspect ratio?

    I added some shots to maybe better visualize what I mean by "outside GUI area"

    default, non fullscreen 1024x768 game window

    fullscreen 1024x768 game on a 1920x1080 display, keeping aspect ratio, mouse "outside"
    [​IMG] [​IMG]

    I dont mind the black borders on different aspect ratios, all I'd need is a good solution to prevent the mouse from acting on them, dont know if there is something built in for that (other than what I already do in solution 1)....

    and sorry if thats maybe an already good documented question, I somehow couldn't find a solution by now :D

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice