2
votes

I am finishing one of my project, a game made with Spritekit. I created a small menu with UIKit (1 view and few buttons). I connected SKScene and View Controller class to communicate so when game is finished, I am able to present menu.

I noticed problems with SKScene FPS. I already found some informations from 2015, on apple developer forum that this problem was spotted with iOS 9 for the first time. When I'm presenting UIView over SKScene, my FPS falls from 60 to 40. And after I hide UIView and run game again, FPS increases back.. But in about 2-3 seconds, what gives me a lag in my animations on start of the game. I tried with preloding all texture atlases first and nothing changed. Than I tought my textures are too big and problem is in my animations, and I decreased all images and its quality from 32bit colors to 16... But problem was not solved.

Then I also noticed that FPS is worse, if I animate UIView.. So there is definetly problem with combining SpriteKit and UIKit. I could pause scene before presenting UIView and unpause second or two after my view disappear again, and yeah maybe users wouldn't notice problem..

But what if I want to run my Scene in background of my UIView (like endless scrolling backgrouns), so background would move constantly when user enter menu? I know, I could do the menu with SpriteKit, but this approach seemed to work fine 2 years ago when I was last time using SpriteKit.

1
Makes me wonder why they made SpriteKit compatible with UIViews, follow UIView interoperability strategies, and designed it to accord with them and their ways.Confused
Exactly... if they don't work together properly, they shouldn't allow to use them together... What's the point if it won't work as it should?MOzeb
I don't know. Is it a badly designed and implemented game engine because the builders only knew to copy ideas from cocos2D and structure code like UIKit, or a game engine hoping to integrate with UIKit that's not yet finished, or some other kind of generalised failure? They've never said, there's no game experts making online commentaries and critiques, and most everybody chooses some other game engine, rolls their own, or limits their use of SpriteKit to very simplistic guff (me).Confused
I also started now with Unity 2D for my games... But this was an old project from 2013 which I build it in SpriteKit and now I rewrited it in swift.. And its a really simple game, not lots of physics and about 20 nodes max at same time presented.. An there was one thing I thought it will be easy to build - menu.. But now I will have to do some walk around :) Surely my last project in SpriteKit:)MOzeb
SpriteKit, GameplayKit and SceneKit can be best thought of as a WIP, patches and sign of intent, in that respective order. I think. So long as you limit yourself to the parts and ideas of SpriteKit that work, and have been shown to work by the few others that use it and talk about it, you'll be fine. This, oddly, means you have to recreate things you'd normally make with UIKit by using SpriteKit. I think it's a lack of interest and focus (by Apple) on SpriteKit that ensures it's so incomplete, incompatible and irritating.Confused

1 Answers

2
votes

Okay.. I am posting an answer, if somebody else is searching a solution for similar FPS problems.

After your comments and recommendations what to do, I tried few different things and figured out some problems.

I tested it on two physical devices iPhone 6S and iPad 2. Of course results on iPad 2 are a bit worse.

UIKit and SpriteKit are surely not working best together. I figured out that there are no big problems with just presenting other UIViews or UIButtons over SpriteKit scene - FPS drops a bit but not really much, that this would make some big impact on your scene (2-3 FPS).

Biggest problems came in if you're trying to animate Views with some basic animations. In that case FPS (in time that animation is happening) drops to 40 - 35 FPS, and the biggest problem with this is, that sometime it just wont raise again until you make another animation or run scene again. I still don't know why this is happening, but it happens randomly. Sometimes FPS raises and sometimes not.

Another thing that also have big impact on SpriteKit frame rate are Ads if you're using them.

I am using AdMobs and in their documentation it's well written, that Banners or Interstitial Ads can make impact on your frame rate. I am not presenting Ads during gameplay, but also if you're presenting them in menu, this will decrease your FPS and when you run your game and your FPS drops again for a bit, the result will be even worse. So I suggest you run your Scene with delay or hide banner a bit earlier so it won't have impact on your start of the game.

I found solution for my problem with pausing the scene as soon as gameplay ends, so when menu appear my Scene is on pause mode. And after I run my game again I am un-pausing my Scene. It's not the best solution for my case, but it works much better now.

I suggest to use SpriteKit also for your menu creation, this way you won't have such problems. Or even better - use some other game engine for your game creation.