GameMaker Views/ cameras are really confusing to me

G

Gyeff

Guest
I've been trying to find how to get the leftmost point of the screen for a while and I haven't been successful. in GM 1.4 it used to be view_xview. In GM 2 I've tried camera_get_view_x and view_xport in a Draw event and both get the top left side of the room... not my view.

I'm already using the gui layer for something else. (that gui layer is smaller and has to be centered because it contains my inventory/character menus. I want to keep it unscaled because the text looks bad when scaled up.)

Is there any way to generate a custom gui layer. It seems like there is a lack of info and the documentation is not clear enough.

I've seen the shaun spalding video on cameras and have set up a camera. Is there anywhere where I can find info about creating new GUI layers?
 
camera_get_view_x(view_camera[0]) will get the x position of view 0.

Have you enabled views. What parameter are you feeding the function?
 
G

Gyeff

Guest
Doesn't work. It draws relative to the room, not the view if I put the draw in the draw event.

Here is my draw event code (on an object that is drawing)
Code:
start_ltx = camera_get_view_x(view_camera[0]);

c= c_white;

draw_text_color(start_ltx, 0, "Gender", c,c,c,c, 1);
here is my camera code:
Code:
var zoom = 2;
var resolution = 1;
var camera_width, camera_height;

var window_setting = 2;

if ((window_setting == 0) or (window_setting == 1)){

camera_width = 640;
camera_height = 480;

}

if ((window_setting == 2)){

camera_width = 512;
camera_height = 384;

}

if ((window_setting == 4)){

camera_width = 640;
camera_height = 360;

}


if (window_get_width() != camera_width * zoom and window_get_height() != camera_height * zoom){
   window_set_size(camera_width * zoom, camera_height * zoom);
   surface_resize(application_surface, camera_width * resolution, camera_height * resolution);
}

display_set_gui_size(camera_width*zoom, camera_height*zoom);


var w2 = display_get_gui_width();
var h2 = display_get_gui_height();


var w1 = window_get_width();
var h1 = window_get_height();



var x2 = ((w2 - w1) /2);
var y2 = ((h2 - h1) /2);

display_set_gui_maximize(1 , 1, x2, y2);

global.maincamera = camera_create();

var vm = matrix_build_lookat(x, y, -10, x, y, 0, 0, 1, 0);
var pm = matrix_build_projection_ortho(camera_width, camera_height, 1, 9999);

camera_set_view_mat(global.maincamera, vm);
camera_set_proj_mat(global.maincamera, pm);


view_camera[0] = global.maincamera;

if (!view_enabled){
   view_set_wport(0, camera_width);
   view_set_hport(0, camera_height);
   camera_set_view_size(view_camera[0], view_wport[0], view_hport[0])
   view_set_visible(0, true);
   view_enabled = true;
}
 
Top