How to get and set tile flip_h flip_v

Godot Version

v4.2.2.stable.official [15073afe3]

Question

Getting flip_h flip_v

  • I create a TileMap.
  • On coords (0,0) of layer 0, I add a tile with horizontal flip.
  • In 2d editor, tile appears horizontally flipped
  • I add a script on the TileMap
  • In the _ready method, I do
var tile_data:TileData=get_cell_tile_data(0,Vector2i(0,0))
print("flip_h?",tile_data.flip_h)

But it says the flip_h is false. What did I miss ?

Setting flip_h flip_v in the context of an import plugin

In this import, I create a TileMap (Resource) which displays just fine when added in a scene, except for flipped tiles. set_flip_h / set_flip_v or directly set matching property on TileData of a cell does nothing. Again, what am I missing ?

Thank you.

Flip and rotate - encoded as alternative tile.

var alt_id = $tilemap.get_cell_alternative_tile(layer_id, cell)
print("flip_v: ", alt_id & TileSetAtlasSource.TRANSFORM_FLIP_V > 0)
print("flip_h: ", alt_id & TileSetAtlasSource.TRANSFORM_FLIP_H > 0)
print("rotated: ", alt_id & TileSetAtlasSource.TRANSFORM_TRANSPOSE > 0)
$tilemap.set_cell(layer_id, cell, source_id, atlas_coords, alt_id | TileSetAtlasSource.TRANSFORM_FLIP_H)