1

Hey I've been working my way through making my first app, and I've hit the first problem that I don't even know how to begin fixing.

I am making a SpriteKit game, and as I've been coding, performance has been slowly dropping. Clearly I am not handling lag well at all. (~20-30 fps on device)

The thing is though, I'm not sure how to tackle this issue. I am going through and trying to loosen the load on each frame, but..

Are there any methods of lag handling that most people use?

I tried setting up a timer system, so that I know how much each segment of code takes to run, but the data wasn't too helpful.

It doesn't even look like a specific segment of code is taking that long at all.

This is kind of a broad question I guess, but how should you go about lag handling in SpriteKit?

grg
  • 5,023
  • 3
  • 34
  • 50
IAmTheAg
  • 351
  • 3
  • 11
  • "Are there any methods of lag handling that most people use?" - Yes, it's called Instruments: https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/InstrumentsUserGuide/Introduction/Introduction.html The very first thing you need to do is to analyze and narrow down where your performance issue is coming from. Also judging by your screenshot you seem to be logging every frame, keep in mind that logging is slow. You should post a screenshot with SKView debugging labels turned on, specifically of interest is the node and draw count. – CodeSmile Feb 22 '14 at 17:36
  • Thanks, I'll check into those! Also I was only logging after I noticed lag, and that was indeed an additional drain on fps. Going to check node count, should have done that earlier... – IAmTheAg Feb 22 '14 at 17:57
  • 1
    @IAmTheAg Could you post some of your code, It's hard to try identify an issue just from a description. Also, have you tried using asynchronous dispatch queues and GCD. If you load the games textures into a singleton instance first, and then reuse that class throughout your project you can also keep the number of times you load a texture down. I wrote an answer to a question about texture preloading in singleton classes [here](http://stackoverflow.com/questions/21868609/sktexture-preloading/21892110#21892110). – Andrew97p Feb 22 '14 at 19:01
  • Also calculate the total nodes hanging from your SKScene, the node count only shows those on screen so if your not cleaning things up properly old nodes might be getting out of hand behind the scenes. – fuzzygoat Feb 22 '14 at 22:53
  • Thanks for all of the tips, bottom line was that I wasn't removing the nodes I wasn't going to be needing anymore :/ LearnCocos and Fuzzy both pointed that out as a possibility, so thanks. Also Andrew brought up a really good point, one that I didn't think about but I will definitely be using now. I hate setting things up like that but it's for the better :) – IAmTheAg Feb 23 '14 at 19:00

0 Answers0