3

I have a sprites.atlas in my SpriteKit game, which I'm experimenting with for the first time. In other game libraries, like cocos2d, there is a lot of savings to be had by creating a spritesheet and using an optimized format like pvr. So I looked at the derived data folder after building the game, and found the sprites.atlasc folder inside the compiled game. This folder contained a single sprite sheet compiled from my individual .png assets (yay!). I noticed the compiled sheet was a .png file, so out of curiosity I decided to upload it to http://tinypng.com, and found that the image could easily have been compressed by 77%.

This suggests to me that either I'm not seeing the final asset, I don't have some settings tuned right, or .atlas files are still not as good as creating a pvr sprite sheet with a tool like TexturePacker. What are the best practices for an asset-heavy 2D game with lots and lots of sprites in SpriteKit for keeping final binary size small?

Zane Claes
  • 14,732
  • 15
  • 74
  • 131
  • SpriteKit will generate an atlas for us at build time. What it does under the hood it's not actually documented anywhere but I doubt it applies any significant optimizations (compression) of a final texture. I guess it's up to us to make all compressions / optimizations needed before atlas is created. There is one optimiziation which Xcode does by default. It's related to term - byte swapping: http://stackoverflow.com/a/2051975, and it should speed up loading images into memory. Because an atlas texture is a png file, I guess that this kind of optimization (if enabled) is applied by default. – Whirlwind Nov 20 '15 at 11:52
  • About resource heavy apps... You can check how to dynamically load the content by using On Demand Resources - https://developer.apple.com/videos/play/wwdc2015-214/ – Whirlwind Nov 20 '15 at 11:58

1 Answers1

-2

SpriteKit's textures, texture packing and texture management have been fundamentally broken in iOS 9, and show no signs of being fixed anytime soon.

Right now there is probably no "best practice" that meets your requirements as I suspect the entire asset management and its procedures are in a state of flux. Perhaps they'll be fixed in iOS 10 in such a way that there's an ideal, but given the debacle that is iOS 9 and Sprite Kit, I doubt it.

If you're not aware of this thread, a read through will give you some idea of the problems: https://forums.developer.apple.com/thread/17463

This one also an interesting read: https://forums.developer.apple.com/thread/14487

The above are indicative of the more general problems with Sprite Kit in iOS 9, and should give you a feel for how immature or otherwise wonky the thing is, as a whole.

More pertinent to your question, things like this go unanswered: https://forums.developer.apple.com/thread/26059

If your question is:

What are the best practices for an asset-heavy 2D game with lots and lots of sprites in SpriteKit for keeping final binary size small?

And we ignore "SpriteKit" in this question, the answers are vastly superior than any option currently available within SpriteKit.

Unfortunately Apple seems to have gone to enormous trouble to promote, posit and claim its game engine technologies as appropriate for asset heavy productions, despite concurrently claiming them to be easy to use and good for casual game development, and getting neither claim to hold up to any scrutiny.

For a brief period towards the end of iOS 8, most of Sprite Kit worked as advertised, but that all changed with iOS 9. Now its texture handling has reverted to the problems prevalent in iOS 7, and some new issues, too.

The Apple forums document significant other problems, and varied performance issues within iOS 9's Sprite Kit, too.

Yet there is no word from Apple that acknowledges these problems, let alone addresses them.

It is wrong to recommend Apple's gaming technologies in their current state. A lack of meaningful criticism of Apple and their game technologies doesn't mean these things are without show-stopping flaws.

Until they really knuckle down and get a product manager focused on their game technologies and release things when they work, I'd say cocos2D-X and one of the commercial texture packers is the best practice for your requirements.

Confused
  • 6,048
  • 6
  • 34
  • 75
  • Okay, but what's the actual answer to the question? You spent a lot of time saying why SpriteKit is bad, but did not answer the question about what the best practices actually are, you just said "the answers are vastly superior..." – Zane Claes Nov 21 '15 at 18:16
  • As I suggest, are you willing to ask the question without the requirement of Sprite Kit? – Confused Nov 21 '15 at 23:01
  • With SpriteKit, it might be faiestr to say that their sprite/texture packing is in a state of flux, and that there is no best practice for your current requirements. – Confused Nov 22 '15 at 22:20