Skip to main content

The "camera_set_view_scale" Function

Syntax#

camera_set_view_scale(camera, mode, xport, yport, wport, hport, [force]);
ArgumentTypeDescription
cameracameraThe camera index to modify (typically view_camera[#])
modeconstantThe scaling mode to use (same as config)
xportrealThe horizontal position to display the camera within the master view
yportrealThe vertical position to display the camera within the master view
wportrealThe horizontal area to display the camera within the master view
hportrealThe vertical area to display the camera within the master view
[force]booleanOptional: Perform scaling even if a resize was not detected

Description#

While the master view defined in config will always fill the entire window, additional views can be created for splitscreen display within the master view. This script applies the same scaling behaviors to splitscreen views as are applied to the master view.

GameMaker currently provides 8 built-in view cameras, numbered 0-7, although custom cameras can be assigned to the view as well. To use a built-in camera, input camera as view_camera[#]. view_visible[#] must be true for the viewport to be displayed.

Note that if the master view is input in this script, it will be ignored.

It is recommended to use the built-in view_width and view_height macros to position and size the viewport relative to the master view. If this script is run in a Step event, inner views will respond to changes in window size with correct scaling. For other events, enabling the optional [force] argument will trigger scaling immediately.

By default, base width/height will be determined by the size of the camera when this script is first run. This can be set with camera_set_view_size or by defining width_base and height_base within a view# section in config.

Example#

camera_set_view_scale(view_camera[1], axis_x, 0, 0, view_width*0.5, view_height);