Set Tile Data At Pixel Icon Set Tile Data At Pixel

With this action you can set the tile data for a tile cell found at a specific position on a tile map layer. The tile data is simply a value that reflects the index of the tile along with the flip, mirror, and rotate values, as well as any custom tile masks that you have used. With this action you first supply the layer to target using the name of the layer (a string) as defined in the room editor, and then the x and y axis in the room to set the tile data for. Note that the tile data will be set for the tile map "cell" in which the given position lands. For example, if your tile set tiles are 16x16, then the tile map layer will hold tiles in cells of 16x16 pixels, so if you use this action to target the room position (8, 8), you will be changing the tile in the cell (0, 0) of the tile map.

NOTE The layer selected must have been defined as a Tile Map Layer in The Room Editor, otherwise you may get errors.

The final argument for the action is the tile data itself. You would normally retrieve the tile data for the tile map cell using the action Get Tile Data At Pixel and then manipulate it using the action Set Tile Data Transform before setting it again with this action. For more information on tile data, please see the GML section on Tile Map Functions.

 

Action Syntax:

Set Tile Data At Pixel Action

Arguments:

ArgumentDescription
LayerThe layer with the tile map to target
XThe position along the horizontal (X) axis to set the tile-data for
YThe position along the vertical (Y) axis to set the tile-data
DataThe tile-data to use for setting the cell at the position

 

Example:

Set Tile Data At Pixel ExampleThe above action block code tests for a mouse click and when one is received it retrieves the tile-data for the cell that coincides with the mouse position. This data is then modified and returned to the tile map layer, rotating the tile in that cell.