Basic Questions about Create Texture Atlas in Xcode

399 views Asked by At

I think I might be using Texture Atlases incorrectly, and wanted to ask for some advice.

I found a few sites online that suggested I create a folder, let's say Ball.atlas, and in there, add my animation frames (ball1, ball2, ball3).

Then drag and drop ball.atlas into my actual Xcode content tree, and then reference that atlas in code like this:

self.ballAtlas = SKTextureAtlas(named: "ball")
self.ballImages.append(self.ballAtlas.textureNamed("ball1"));
self.ballImages.append(self.ballAtlas.textureNamed("ball2"));
self.ballImages.append(self.ballAtlas.textureNamed("ball3"));
self.ballImages.append(self.ballAtlas.textureNamed("ball4"));
self.ballImages.append(self.ballAtlas.textureNamed("ball5"));

and then I can reference self.ballImages to display the animation, etc.

I saw another guide, however, that said to simply go to your xcassets folder, and click '+', and hit 'new texture atlas', and it creates a folder. Then simply drag the ball images in there.

There is one fundamental difference here, however: in the second approach, you can specify the @1x, @2x, @3x, whereas in the first example (dragging the folder) there is no way to specify.

What should I be doing? Should I not be dragging anything, and instead simply put all atlases inside the xcassets collection?

Thanks!

0

There are 0 answers