Jump to content
  • entries
  • comments
  • views

programming iOS using SpriteKit chapter 3



The game part of my iOS app is 90% done. (Which all programmers know means there's still 90% left to do.) But the big challenges have been conquered - the touch & tilt controls and physics works. There's still some to-dos to load a level, do a reset, handle pause etc. but they will wait until I get the level builder working. However, before I did that I wanted to take a look at performance.

One of the cool things with iOS development is you can easily test out the app on an actual device. Plug in an iPhone, iPad or iPod Touch and click run. It even links into the debugger. The thing which concerned me was my tutorial level was running at only 40fps on my 5th gen iPod Touch. This is about the slowest iOS 9 device so if I can keep the framerate up on it I'd probably be good on anything else. And while 40fps isn't bad, the tutorial level is fairly simple so it's possible some complex level might be unplayable.

Unfortunately the GPU analysis wasn't giving me much of a hint. Both the Tiler and Renderer were at 75% and CPU was less than 20% - so no absolute bottlenecks. I could walk through the OpenGL call stack for a frame, which was interesting but not very useful. So I started changing the code to see what made a difference. Turning off a couple of recent additions didn't make a difference. Nor did removing some logic from the update loop or removing my shader. Moving the textures into a texture atlas reduced the number of draw calls and provided a minor increase, but not much.

But the texture atlas also seemed to weird out the dynamic lighting. Hmm... comment out the dynamic light - 60fps. Ahh-ha! And it turns out texture atlases don't work with normal maps for some reason - which was causing the visual problems. So I guess I'll make that an optional setting.

It also got me to thinking. I was also using the normal map textures to generate the physics bodies via the alpha channel. But the process was less than perfect. So if I decided to discard the dynamic lighting entirely, I'd need to generate the physics bodies manually - which would remove the imperfections as well.


Recommended Comments

There are no comments to display.

Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...