Skip to content

Instantly share code, notes, and snippets.

@KyleGoslan
Created March 2, 2017 10:28
Show Gist options
  • Save KyleGoslan/4e5d27a80adc12aa05537c5bbdc15cd1 to your computer and use it in GitHub Desktop.
Save KyleGoslan/4e5d27a80adc12aa05537c5bbdc15cd1 to your computer and use it in GitHub Desktop.
Method that loops through each tile, with a callback that return the col, row and tile definition.
extension SKTileMapNode {
func loopThroughTiles(completionClosure: (_ col: Int, _ row: Int, _ tile: SKTileDefinition?) -> ()) {
for col in 0..<numberOfColumns {
for row in 0..<numberOfRows {
completionClosure(col, row, tileDefinition(atColumn: col, row: row))
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment