Set Tile Data At Pixel


With this action you can set the tiledata for a tile cell found at a specific position on a tilemap layer. The tiledata 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 tiledata for. Note that the tiledata will be set for the tilemap "cell" in which the given position lands. For example, if your tileset tiles are 16x16, then the tilemap 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 tilemap.

NOTE: The layer selected must have been defined as a Tilemap Layer in the room editor, otherwise you may get errors.

The final argument for the action is the tiledata itself. You would normally retrieve the tiledata for the tilemap 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 tiledata, please see the GML section on Tilemaps - Tile Functions.

Action Syntax:

Set Tile Data At Pixel Syntax


Argument Description
Layer The layer with the tilemap to target
X The position along the horizontal (X) axis to set the tiledata for
Y The position along the vertical (Y) axis to set the tiledata
Data The tiledata to use for setting the cell at the position


Set Tile Data At Pixel Example

The above action block code tests for a mouse click and when one is recieved it retrieves the tiledata for the cell that coincides with the mouse position. This data is then modified and returned to the tilemap layer, rotating the tile in that cell.