Reputation:
I am getting very frustrated with XCode today. I already looked at the answer to this question: Sprite Atlas and @2x images but, that answer did not work.
So, here's the problem:
-I have a sprite in XCode with dimensions 178x50, and in my code, I load [SKSpriteNode spriteNodeWithImageNamed:@"image"];
and that code runs just fine. My image is named "[email protected]" and is in my project.
So today, I wanted to animate it. I made the files, named "default01.png, default02.png .... default10.png", and put them in a folder with .atlas extension. Dragged into my project, added them, changed my line of code to [SKSpriteNode spriteNodeWithImageNamed:@"default01"];
Just to make sure everything was working. Loaded up the game, and the sprite was displayed much larger than normal. Doh, forgot to add the @2x suffixes. So, I went through and added them... same problem continued. I saw the above answer on this site, so I deleted the atlas, made a new one with the @2x suffixes already added, and THEN added that one to the project. Still same problem!
In my element inspector (I believe that's what it's called), I can see that the dimensions for the two images are literally exactly the same. They look identical. They both have @2x suffixes. Yet loading from the atlas displays the image at a much larger size.
No idea what to do.
Upvotes: 0
Views: 488
Reputation: 12782
So if you're using a texture atlas, a folder ending with .atlas to hold the images, you should use the texture method not the image method. Also, you need to explicitly set the size of the sprite at the size you want or it will interpret the size from the image size.
Upvotes: 2