tile_set_region

Sets the region of its background a tile is taken from.

Syntax:

tile_set_region(index, left, top, width, height);


Argument Description
index The index of the tile to set.
left The tile's left position relative to the background's top left corner.
top The tile's top position relative to the background's top left corner.
width The tile's width.
height The tile's height.


Returns: N/A


Description

With this function you can resize the tile indexed. For example, if you have a tile that is a 16x16 square taken from a background image asset and then use this function to set the region to 16x32, the tile will now be a rectangular section of the background. this function does not scale the image in anyway, it changes the shape of the area used to create the tile. This is not permanent and if the player leaves the room and returns to it again, the tile will have its original shape (if it was placed in the room editor and the room is not persistent).


Example:

var tile;
tile = tile_layer_find(-1000, mouse_x, mouse_y);
tile_set_region(tile, 0, 0, 32, 64);

The above code will check the mouse position for a tile and store its index in a variable. This is then used to set the region of the tile to a different part of the background asset it uses.


Back: Background Tiles
Next: tile_set_scale
© Copyright YoYo Games Ltd. 2018 All Rights Reserved