camera_create_view


Description

This function will create a new camera and then set its view into the room, before return the unique ID value to identify the camera in future function calls. The camera will be created using the values that you set in this function for position, size and other details which correlate to the values you set in the Room Editor (see here). Note that this function can take a variable number of arguments with only the x/y position and width/height arguments being obligatory. Any arguments not supplied will use their default arguments.

Note that cameras are like all dynamic resources and will occupy memory when created. This means that you need to take care not to create cameras unnecessarily and to destroy those that you don't need by calling the function camera_destroy(). This also means that cameras will persist from room to room if assigned to a global variable (they will persist when assigned to instance or local variables too, but you can't access them after changing room, hence the memory leak), so that you can - for example - create a new camera, assign it to a global variable, and then at the start of each room use the camera_set_* functions to set the properties before assigning it to a view port.


Syntax:

camera_create_view(room_x, room_y, width, height, [angle, object, x_speed, y_speed, x_border, y_border])


Arguments:

Argument Description
room_x The x position (within the room) of the left side of the area the camera view captures.
room_y The y position (within the room) of the top of the area the camera view captures.
width The width of the area the view captures.
height The height of the area the view captures.
angle The angle to set the for the camera view(from 0° - 360°, default is 0).
object The object ID (or instance ID) for the camera view to follow (default is -1, no object).
x_speed The maximum horizontal speed the view can move at (set to -1 for "instant" following, default is -1).
y_speed The maximum vertical speed the view can move at (set to -1 for "instant" following, default is -1).
x_border The minimum horizontal space between the edge of the view area and the instance it is set to follow (before the view begins moving and if it is set to follow an instance, default is 0).
y_border The minimum vertical space between the edge of the view area and the instance it is set to follow (before the view begins moving and if it is set to follow an instance, default is 0).


Returns:

Real (unique camera ID value)


Example:

view_camera[0] = camera_create_view(0, 0, 640, 480, 0, obj_Player, 5, 5, -1, -1);

The above code creates a new camera, defines its view porperties and then assigns its ID to view port[0].


Back: Cameras
Next: camera_destroy
© Copyright YoYo Games Ltd. 2018 All Rights Reserved