'swift/spritekit/tilemap: how to rotate single tile?

I have (programmatically) created a tilemap in SpriteKit, I can check if a tile has been tapped and i can get the row and the col of the tile within the tileset.

but I cannot get the tile to be rotated or flipped etc.

Here is my code in touchesEnded where i handle this:

override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
    let touch:UITouch = touches.first!
    let location = touch.location(in: self)
    let touchedNode = self.atPoint(location)
    
    if let name = touchedNode.name
    {
        let tempRow = tileMap.tileRowIndex(fromPosition: location)
        let tempCol = tileMap.tileColumnIndex(fromPosition: location)
        let tile = tileMap.tileDefinition(atColumn: tempCol, row: tempRow)

        tile!.rotation = SKTileDefinitionRotation.rotation90
        tile!.size = CGSize(width: 500, height: 500)
        
    } else {
//      print("no name found!")
    }
}

in override func didMove I have defined the tileMap:

var tileMap = SKTileMapNode()
tileMap = SKTileMapNode(tileSet: tileSet, columns: colums, rows: rows, tileSize: tileSize)

I can see the tileMap with the correct tiles showing up, i can tap them, but they do not rotate or flip or change size

What i am doing wrong?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source