surface_copy_part

Copies part of a source surface onto a destination surface (without any form of blending.)

Syntax:

surface_copy_part(destination, x, y, source, xs, ys, ws, hs);


Argument Description
destination The ID of the surface to copy the other surface to.
x The x position to copy to.
y The y position to copy to.
source The ID of the surface to be copied.
xs The x position in the source surface to copy from.
ys The y position in the source surface to copy from.
ws The width of the area in the source surface to copy from.
hs The height of the area in the source surface to copy from.


Returns: N/A


Description

This function simply takes the image from one surface and copies it onto another one at the specified local position within that surface (where the (0,0) position is the top left corner of the destination surface). You can specify a local x and y position to copy from as well as the width and height of the section. Please note that these are coordinates based on the surface size and not on the position at which the surface is being drawn in the room (see the main page on Surfaces for further information). If the destination surface already has information this will be overwritten by the copy, and the function does not change the source surface in any way.

NOTE: When working with surfaces there is the possibility that they can cease to exist at any time due to them being stored in texture memory. You should ALWAYS check that a surface exists using surface_exists before referencing them directly. For further information see Surfaces.


Example:

if view_current == 0
   {
   surface_copy_part(surf, 0, 0, temp_surf, 0, 0, view_xview[1] - mouse_x, view_yview[1] - mouse_y);
   }
else
   {
   draw_surface(surf, 0, 0);
   }

The above code will check the current view being drawn and if it is view[0] it copies the surface indexed in the variable "temp_surf" onto the surface indexed in the variable "surf". the area copied corresponds to a rectangle formed by the relative position of the mouse within the surface as it would be drawn in view[1]. If the current view is anything other than view[0] the surface "surf" is drawn to the screen.


Back: Surfaces
Next: surface_get_height
© Copyright YoYo Games Ltd. 2018 All Rights Reserved