2

I don't find a way to use this sort of images as tile set for my games. Is there a way to do it, or should I add all object I want one by one ?

I tried to add a new Grid Tile Set then a Single Tile Group, but if I try to use this in a Tile Map Node, it will use all the image as texture for one block.

I don't know if it's possible, but if you can help me, I would be grateful.

Mark Brownsword
  • 2,287
  • 2
  • 14
  • 23
Marsgames
  • 113
  • 9
  • 1
    The [Tiled Map Editor](http://www.mapeditor.org/) can read this kind of Tileset. Read more in this [Introduction to Tiled Map Editor](https://gamedevelopment.tutsplus.com/tutorials/introduction-to-tiled-map-editor-a-platform-agnostic-tool-for-level-maps--gamedev-2838) article. Though this is not compatible with `SKTilemapNode` in SpriteKit, you would need to do extra work to use the map in SpriteKit. – Mark Brownsword Nov 11 '16 at 20:01

2 Answers2

3

Unfortunately you will have to separate the image into smaller images manually..

The functionality you want just doesn't exist.

Alec.
  • 5,371
  • 5
  • 34
  • 69
2

You can use your image as a texture atlas, but you will not be able to use SKTextureAtlas, you will have to break them out your self.

If you look at SKTexture, you have an init called init(rect: CGRect, in: SKTexture). This will create a new SKTexture object for you, while still referencing the texture memory space of the original texture. You are just going to have to use something like a plist to load in all of the CGRRect info to create this atlas.

Example:

let textureAtlas = SKTexture(imageNamed:"CEm72.png")  //I convert your jpg to png somehow
let rectDarkKnight = CGRect(x:0,y:96,width:32,height:32)
let texDarkKnight = SKTexture.init(rect: rectDarkKnight, in: textureAtlas)
Knight0fDragon
  • 16,609
  • 2
  • 23
  • 44
  • 1
    Thankfully your texture map is not optimal. It gets even crazier with optimized textures, because you have to grab the minimal amount from the atlas, and pad the rest on the sprite. I do not know of anyway to handle the padding from an SKTexture – Knight0fDragon Nov 11 '16 at 17:55