GameMaker Studio 2 has a list of obsolete function, including View Variables And Windows Functions.
From https://docs2.yoyogames.com/ , GMS2 introducing a camera function.
With the advent of the camera functions in GameMaker Studio 2, it means that a number of view variables are no longer required, specifically those referring to the view into the room rather than the view_port (which is still used). There are also a few functions for controlling how things are displayed that were available in legacy versions of GameMaker: Studio 1.4 which are also no longer appropriate. These variables and functions are listed below:
view_object view_angle view_xview view_yview
view_hview view_wview view_hborder view_vborder
view_hspeed view_vspeed
display_set_windows_vertex_buffer_method
display_get_windows_vertex_buffer_method
display_set_windows_alternate_sync
display_get_windows_alternate_sync
room_set_view
With the advent of the camera functions in GameMaker Studio 2, it means that a number of view variables are no longer required, specifically those referring to the view into the room rather than the view_port (which is still used). There are also a few functions for controlling how things are displayed that were available in legacy versions of GameMaker: Studio 1.4 which are also no longer appropriate. These variables and functions are listed below:
view_object view_angle view_xview view_yview
view_hview view_wview view_hborder view_vborder
view_hspeed view_vspeed
display_set_windows_vertex_buffer_method
display_get_windows_vertex_buffer_method
display_set_windows_alternate_sync
display_get_windows_alternate_sync
room_set_view
view_xview[0] = x - view_wview[0]/2;
view_yview[0] = y - view_hview[0]/2;
Alternative script for GMS2:
var view_xview = x - camera_get_view_width(view_camera[0]);
var view_yview = y - camera_get_view_height(view_camera[0]);
camera_set_view_pos(view_camera[0], view_xview/2, view_yview/2);
var view_yview = y - camera_get_view_height(view_camera[0]);
camera_set_view_pos(view_camera[0], view_xview/2, view_yview/2);
or obviously you can write it like this:
var view_wview = camera_get_view_width(view_camera[0]);
var view_hview = camera_get_view_height(view_camera[0]);
var view_xview_c = x - view_wview/2;
var view_yview_c = y - view_hview/2;camera_set_view_pos(view_camera[0], view_xview_c, view_yview_c);
So we got a substitute for the code! We can continue to follow the GMS1 tutorial from youtube.
Well, not the greatest solution, but it works.
screenshake?
^_^