Gamemaker Virtual keys on different screen resolution

Hello all,

Currently I am developing an android game. The controls are virtual keys positioned like view_xview[0]+20, view_yview[0]+20, which mostly does the trick expect that on different devices, the virtual keys are drawn in different places.

I am drawing icons above the virtual keys to represent buttons which do the same thing.

Does anyone know of a tutorial that deals with this sort of problem?

A demo of the apk can be found at www.broken-skies.com/broken1.apk

Comments

  • Isn't that the expected behavior of using co-oridnates relative to the screen corner to draw stuff? You're going to get different sizes of view on different devices, so your buttons are going to move around as your game is played at different resolutions. This is a good thing ;)

    What's the problem - are your graphics not using relative co-ordinates as well?
  • I thought that they would be relative. On my Hisense infinity the buttons are in the right place. On a samsung galaxy s3 they are way off (much too high) its totally confusing!
  • So is the issue that the view_yview[] values aren't returning accurately? Are you using views, or are you expecting those to be populated for you?

    Surely there must be other values for screen size and height that are device based, like the window_* calls?
  • I am using views. This is my code:

    The virtual keys:
    virtualLeft = virtual_key_add(view_xview+10, view_yview+550, 80, 80, ord('Q'));
    virtualRight = virtual_key_add(view_xview+151, view_yview+550, 80, 80, ord('W'));
    virtualFire = virtual_key_add(view_xview+846, view_yview+550, 100, 100, ord('O'));

    the drawing of the buttons:

    draw_sprite(sprLeftTurn,0,view_xview+10,view_yview+550)
    draw_sprite(sprTurnRight,0,view_xview+151,view_yview+550)
    draw_sprite(sprFire,0,view_xview+846,view_yview+550)

    Thanks for putting me onto window_ calls. I will check to see if I cant use these.
  • I think what's probably happening is GM is trying to make your views be as you set them up, but the actual res of the different devices is messing that up (because it's trying to keep your pixels square or something). If you're not doing special logic to make sure your views are the correct size for whatever device you're running on, then that's probably the root of the issue.
  • The fix that I had to implement was to create the virtual keys and the images that appear over them using Draw_GUI not just Draw, and set the resolution to max_device otherwise the x,y co-ordinates go haywire.

    The game is on the play store https://play.google.com/store/apps/details?id=com.companyname.BrokenSkies&hl=en
Sign In or Register to comment.