Skip to content

Instantly share code, notes, and snippets.

@retrokid
Last active July 25, 2017 08:30
Show Gist options
  • Select an option

  • Save retrokid/3e59bfb0c2f17e1d69f774ae3f44e68c to your computer and use it in GitHub Desktop.

Select an option

Save retrokid/3e59bfb0c2f17e1d69f774ae3f44e68c to your computer and use it in GitHub Desktop.
// Check user data in the tile under the player’s sprite
// Convert the player’s position into the tile map’s frame of reference
let position = tileMap.convert(playerSprite.position, from: playerSprite)
// Get the column and row of the tile that contains the position
let column = tileMap.tileColumnIndex(fromPosition: position)
let row = tilemap.tileRowIndex(fromPosition: position)
// Get the tile definition in the tile the player’s sprite is over
guard let definition = tileMap.tileDefinition(atCoulumn: column, row: row) else { return }
// Access custom user data on the tile definition
let customUserData = definition.userData?.value(forKey: "MyKey")
@retrokid
Copy link
Author

accessing userData in a tilemapnode spriktekit3 tilemapeditor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment