I'm having the following issue with SpriteKit. I'm presenting a modal viewController from another viewController which view is a SKView, the problem is that the SKScene in the SKView freezes when i dismiss the modal viewController, and it unfreezes if I present and dismiss the modal view again. It's toggling...
The weird thing is that when the scene unfreezes I can see that animations continued in the background as the sprites are in different positions than they where before the freeze.
To make things weirder, it only happens when testing in the actual device, not in the simulator.
I saw this question: iAds and SpriteKit: SKScene Freeze on fullscreen exit on device only but it has no answer and the problem is when using iAds. I've read in other forums that it can be solved by removing self.canDisplayBannerAds = YES
, but I'm not using iAds at all.
Please help, i'm desperate.
I had almost the same problem, this link helped me Go from SKView back to UIView
The point is to make your skView a subview of an UIView and then make an IBOutlet that link to your skView.
That work with and without iAd Banner (in my case I made the banner a subview+iboutlet as well)
How to reproduce the effect:
Preparation:
Action:
How to Solve the problem:
Show the assistant editor with storyboard and ViewController.h
control-drag the skview to the interface and create an IBOutlet named skView
ViewController.h:
#import <UIKit/UIKit.h>
#import <SpriteKit/SpriteKit.h>
@interface ViewController : UIViewController
@property (strong, nonatomic) IBOutlet UIView *skView;
@end
in ViewController.m comment line 19 and replace skView by self.skView
- (void)viewDidLoad
{
[super viewDidLoad];
// Configure the view.
//SKView * skView = (SKView *)self.view;
self.skView.showsFPS = YES;
self.skView.showsNodeCount = YES;
// Create and configure the scene.
SKScene * scene = [MyScene sceneWithSize:self.skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
// Present the scene.
[self.skView presentScene:scene];
}
Run and now no more freeze
Regards
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With