I am creating a round based game where I have a playground as a SKTileMapNode with grass textures on every tile where characters can walk from tile to tile. Every character has his own reach where they can walk in one round. I want to display this range so that the player can see the range of the selected character. My question: How can I change the color of those tiles which are in the range of the tile where a specific character is on? SKSpriteNode with textures can simply change their color by .color
and .colorBlendFactor
so that my green grass texture gets for example a red touch. How am I able to do this with specific tiles in a SKTileMapNode?
Asked
Active
Viewed 465 times
0

T. Yueksel
- 69
- 1
- 10
1 Answers
0
let tile = tileMap.tileDefinition(atColumn: column, row: row)
Once you have the tile you can modify the textures of the tile tile.textures
to either include tinted textures or draw the colored textures yourself (messy but here's an example of that).
I would recommend a different approach though of getting the center of the tiles tileMap.centerOfTile(atColumn: column, row: row)
you'd like to color and using this and their size tileMap.tileSize
to create nodes SKSpriteNode
above the tiles you'd like to be colored.

Hamer
- 1,354
- 1
- 21
- 34
-
How are you going to select a particular tile, then? – El Tomato Mar 21 '19 at 19:21
-
You should read my question again. As @ElTomato already asked, the task is to change the color of specific tiles, not the whole tile map node – T. Yueksel Mar 21 '19 at 19:29
-
My apologizes, I did not fully read the question, hopefully my edit helps. – Hamer Mar 21 '19 at 19:56
-
I also had both ideas, but having every texture in a colored version isn't a nice solution as you already mentioned. Also I wanted to avoid creating SKSpriteNode for specific tiles since a SKTileMapNode itself is like an Array of SKSpriteNodes in one node, but from my knowledge without the same supporting functions/attributes as in SKSpriteNode for the single tiles inside a map. Thanks for your contribution – T. Yueksel Mar 21 '19 at 20:24