Reputation: 123
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.
Upvotes: 3
Views: 1226
Reputation: 16847
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)
Upvotes: 3
Reputation: 5535
Unfortunately you will have to separate the image into smaller images manually..
The functionality you want just doesn't exist.
Upvotes: 3