6

If you're in the Assets.cxassets folder and hit the plus sign, you can among other things add a new "sprite atlas" and/or new folder.

when you create either a "sprite atlas" or folder from this menu they both look exactly the same. I was under the impression that an atlas folder had to have the suffix ".atlas" at the end of it?

I read that using a sprite atlas is generally better for a lot of repeated textures on screen. I created a "sprite atlas" inside Assets.cxassets when I started my project and have been putting all of my images into that folder.

The more I'm reading about it the more I think I did it incorrectly. I can't find a single thing online about having your "atlas" folder inside Assets.cxassets. and when I created the atlas folder like I mentioned above it didn't have the ".atlas" suffix, it just had a generic name of "sprites"

I'm also using all of these sprites with a tile set, is using an .atlas in a tile set common practice?

thanks for all advice.

genericguy25
  • 602
  • 3
  • 16

1 Answers1

9

Yes, it is an actual atlas.

When you open assets catalog from your Project Manager and add things like atlases, groups (folders) or say, Watch Complication, those might look the same to you in the Xcode...

assets

But behind the scenes those are not the same. This is how these folders look on disk:

enter image description here

So, if you right click on the assets catalog, and select Show In Finder, you will notice that there is .spriteatlas extension on Atlas folder, .complicationset extension on Complication folder and that there is no extension found on New Folder. This means that each folder from assets catalog actually has its own type defined by its extension.

This is from the docs:

The type of content represented by a folder is encoded in the extension for the name of the folder. For example, a folder named PosingLlamas.imageset has a type of imageset.

So, you can conclude that, if you are interested in sprite atlas features, you must create a new sprite atlas, rather than a group (folder), and Xcode will do the rest for you. Otherwise batch rendering (rendering multiple textures in a single draw pass) would not work which is the main feature of sprite atlases and helps with performance greatly.

Whirlwind
  • 14,286
  • 11
  • 68
  • 157
  • Thank you very much for the detailed explanation! – genericguy25 Jul 27 '17 at 12:49
  • 1
    From what I'm seeing in Xcode 11, yes the spriteatlas extension is created, however looking inside the generated CAR file within the app binary, there is no sprite atlas being generated. all of the individual images are still there. – PKCLsoft Jun 05 '20 at 04:02
  • @PKCLsoft I see the same thing, no atlas is created, instead the individual images are there, and the draw calls are not batched either. Xcode 13. – Calin Nov 13 '21 at 17:26
  • @Calin Yes, I remain unconvinced that there is any performance gain; the only advantage is the app thinning, and the elimination of the need to have image assets for every device resolution like the old days. – PKCLsoft Nov 14 '21 at 21:53
  • @PKCLsoft I agree. I also cannot express how this affects performance since I haven't had a problem with draw calls not being batched, but it is still a very weird behavior. Apparently Xcode adds the individual images as well as the atlas into the bundle, and it doesn't batch the draw calls when the atlas from the bundle is used. For more details, you can take a look at https://stackoverflow.com/questions/69957326/spritekit-draw-calls-not-batched-when-using-a-texture-atlas-from-data-stored-in which shows two different methods of having draw calls batched or not. Which seems like a bug to me. – Calin Nov 14 '21 at 22:01