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
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).
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.