Last active
July 25, 2017 08:30
-
-
Save retrokid/3e59bfb0c2f17e1d69f774ae3f44e68c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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") |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
accessing userData in a tilemapnode spriktekit3 tilemapeditor