Get Tile Data At Pixel


Description

With this action you can get the tiledata for a tile cell on a tilemap layer from a position. 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 get the tiledata for. The tiledata value returned will coincide with whatever tilemap cell happens to be at that point. 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 getting the tiledata for 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 returned value will then be stored in the target variable which can have been created previously or can be a new temporary one (if you check the "Temp" check-box). For more information on tiledata, please see the GML section on Tilemaps - Tile Functions.


Action Syntax:

Get Tile Data At Pixel Syntax


Arguments:

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


Example:

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.