GML Questions about views

TheOnlyWRT

Member
Hey guys, so i would like to program in my own views using GML instead of making them in the room editor. I have read a few tutorials about views and i dont completely understand how to code them in. For example, do i put the code in my players object? or in a controller object?

also, if anyone has a link to a very basic, clear, straight foreward guide/tutorial, that would rule. Thanks!
 

Jakylgamer

Member
this is basically all you need to make a camera in a script
run this in the players create event.
Code:
_index  = 0;//index of the view you want to target
_width  = 960;//set the value port width
_height = 540;//set the value port height

view_enabled = true;//enable the view
view_set_visible(_index, true);//set it to be visible
view_set_wport(_index, _width);//assign the port width
view_set_hport(_index, _height);//assign the port height
//resize game window and center it
window_set_rectangle(display_get_width()/2-view_wport[_index] / 2,display_get_height()/2 - view_hport[_index] / 2,_width,_height);
//resize the application surface (for gui purposes)
surface_resize(application_surface,_width,_height);
//create a camera
camera = camera_create_view(0, 0, _width, _height, 0, obj_player, -1, -1,_width/2, _height/2);
//assign the camera
view_set_camera(view_camera[_index],camera);
alternatively you can set the camera position using
Code:
camera_set_view_pos();
if you want to have control over that
 

Jakylgamer

Member
this does it change the obj_player to your player objects name then its good to go

camera = camera_create_view(0, 0, _width, _height, 0, obj_player, -1, -1,_width/2, _height/2);
 
Top