tile_set_position(index, x, y);
Argument | Description |
---|---|
index | The index of the tile to set. |
x | The tile's new x position. |
y | The tile's new y position. |
Returns: N/A
With this function you can move a tile from one part of the room
to another by setting the (x,y) coordinates. These are absolute
coordinates within the room, and the origin of a tile is always the
top left corner, so setting the tile position to, for example,
(64,45) will position the top left corner of the tile at that
position. This is not permanent and if the player leaves the room
and returns to it again, the tile will have its original position
(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_position(tile, mouse_x - 100, mouse_y - 100);
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 position of the tile to the mouse position minus 100.