2

I read that when I add images into the xcassets file, if they are grouped SpriteKit will combine them into atlas structures.

Currently I'm creating atlas folders with internal folders on my Mac, then I drag and drop this folder into my project's folder structure, then I'm dragging that folder from the projects folder structure into the xcassets file.

Break down of atlas folder:

example.atlas (folder)
-> ex_0 (folder)
--> ex_0.png
--> ex_0@2x.png
--> ex_0@3x.png
-> ex_1 (folder)
... and so on...

Is this correct? Should I create the subfolders, or should all images be in the atlas folder? Do I need to put the atlas into the xcassets file?

Lastly, say that these images are tiles, and I will have multiple different tiles, say example2,atlas, example3.atlas, etc. If I plan to use all these tiles at the same time, should I combine them into 1 big atlas folder?

thanks for any help, I understand that there are multiple ways to do things. I guess I'm looking for the most efficient way to increase performance in my apps. The answer may depend on certain things. So if you could explain the far left and right's of this situation, I can use common sense to figure out what to do when my situation is somewhere in the middle.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Discoveringmypath
  • 1,049
  • 9
  • 23

1 Answers1

1

You don't need to create extra folders. Just add the regular size image, and then if you click on it, you will notice that on the right there is a way to add the 2@ and 3@ versions.

enter image description here

For tiles you can create a tile set, and in this case you don't need to make any effort combining them into an unique image, because Xcode does all the job for you. It's already optimized.

Ramy Al Zuhouri
  • 21,580
  • 26
  • 105
  • 187
  • Thanks for the comments. So for a tileset, I don't need to add them to the xcassets? – Discoveringmypath Jun 10 '17 at 21:50
  • Also should I fit as much into an atlas, if all images are going to be used together? – Discoveringmypath Jun 10 '17 at 21:51
  • @Discoveringmypath You first add the images to the xcassets folder, then you create a tile set. In the tile set you can import images from your assets. This means that the 1x, 2x, 3x versions will be loaded automatically, depending on the screen resolution. – Ramy Al Zuhouri Jun 11 '17 at 10:00
  • sorry I interpreted what you said wrong, I understand how the tile sets work. What do you think about my atlas question? – Discoveringmypath Jun 11 '17 at 14:51
  • @Discoveringmypath I am not sure if 've understood your question. Are you asking if it's convenient to create an atlas when you are sure that the images will be used together, rather than adding individual images to the xcassets folder? – Ramy Al Zuhouri Jun 11 '17 at 16:18
  • I have been reading in other places that it is good to cram as many images into an atlas as possible, instead of separating them into separate atlas's. I was just trying to verify if this is true... – Discoveringmypath Jun 11 '17 at 16:20
  • 1
    Yes, it's more efficient but for the sake of usability I suggest to put only related images in the same atlas. – Ramy Al Zuhouri Jun 11 '17 at 18:55