tile_add

Adds a new tile to the room, allowing customisation of its attributes, and returning its index.

Syntax:

tile_add(background, left, top, width, height, x, y, depth);


Argument Description
background The background asset from which the new tile will be extracted.
left The x coordinate of the left of the new tile, relative to the background asset's top left corner.
top The y coordinate of the top of the new tile, relative to the background assets top left corner.
width The width of the tile.
height The height of the tile.
x The x position in the room to place the tile.
y The y position in the room to place the tile.
depth The depth at which to place the tile.


Returns: Real


Description

With this function you can add a tile into the game at any position within the room. You need to give it a background image as a base asset and the position within that image to extract the tile, then a position within the room and a depth to place it at. The function returns the unique index number for that tile that should be stored in a variable if you plan to change it in any way later (however, you can also get this index at a later date by using the tile_layer_find function).


Example:

tile_add(back0, 0, 0, 32, 32, 64, 64, 99999);

Takes a 32x32 pixel area from (0,0) of back0, placing it at (64,64) in the room at a depth of 99999.


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