Screen size stuff, I don't get it :( [SOLVED (sort of)]

Hi!

So I'm making a mobile game and have prototyped it for Windows and it works exactly as intended. Now, to prep it for mobiles (android) I've been implementing virtual_key_add() to use as taps on the screen. It seems to work fine except for the coordinates. I'm adding the virtual keys in the Draw GUI event as I read that in the documentation, but it gets messed up when I try to define the key areas using camera_get_view_height() and ..._width.
I know the coordinates, or rather size of stuff, isn't the same in the Draw GUI event as in the Draw event. So how do I get this to work:

Code:
deci_height = camera_get_view_height(view_camera[0])/10;
half_width = camera_get_view_width(view_camera[0])/2;
full_width = camera_get_view_width(view_camera[0]);

virtual_key_add(0, deci_height*6, half_width, deci_height*3, vk_left);
virtual_key_add(half_width, deci_height*6, half_width, deci_height*3, vk_right);
virtual_key_add(0, deci_height*4, full_width, deci_height*2, vk_up);
virtual_key_add(0, deci_height*9, full_width, deci_height, vk_down);
virtual_key_add(0, 0, full_width, deci_height*4, vk_escape);
Right now "deci_height*4" is like almost the full height of my screen. Which variables should I use to get my intended result and how do I get them?
 
Bump.

This bump might be a violation of the forum guidelines as it states
  • Be patient.
    Everything takes time. So does giving and getting help. It might take your topic some hours, even a few days, to get a response. Don't get disheartened and try to solve the problem on your own in the meanwhile. Do NOT keep replying to the topic to beg for help. Such replies will be removed and appropriate actions will be taken.
But I just want this topic on the first page, is that ok?
 

RangerX

Member
The GUI layer is on top of the application surface (your game drawn on it) so on the GUI layer its having its own set of coordinates.
You have to think that 0,0 should be top left of your screen and always make the GUI layer the size of your display or displayed window.
 

Rob

Member
Ok! I didn't know that the GUI layer was changeable, I'll look into that if you all can't point me in the right direction?
I haven't used virtual keys before but it says here to use the draw_gui layer. Therefore your x/y coordinates need to reflect this as RangerX said. Top left is 0,0 and bottom right would be the width of the game view / height of the game view.

Code:
sprWidth = spr_get_width(spr_button);
sprHeight = spr_get_height(spr_button);

virtual_key_add(0, 0, sprWidth, sprHeight, vk_left);
Assuming spr_button has an origin in the top left, this code would draw a button in the top left corner of the screen all the time.
 
I haven't used virtual keys before but it says here to use the draw_gui layer. Therefore your x/y coordinates need to reflect this as RangerX said. Top left is 0,0 and bottom right would be the width of the game view / height of the game view.
Yeah, I get that, it's just that I've been getting the camera view width and height, how do I get the width and height of the GUI layer?
 
Top