I'm building an app using Spritekit, I use UISwipeGestureRecognizer to swipe between scenes.
Now, my app is going to have a lot of scenes based on the same code, and the swipe gesture works well, except once I add a third or fourth scene I get a lot of swipe lag.
I'm not sure if it's because I'm using too many scenes or if it's because each scene uses a background image.
The swipe works but it suffers from a significant lag.
Am I the only one getting this issue? Has anyone found a work around for this kind of lag?
Any help would be appreciated.
Here's an example of the code used for 1 scene.
Thank you
#import "Ep1Slide1.h"
#import "Ep1Slide2.h"
-(id)initWithSize:(CGSize)size {
if (self = [super initWithSize:size]) {
self.backgroundColor = [SKColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0];
CGImageRef backgroundCGImage = [UIImage imageNamed:@"backgroundImage1"].CGImage;
SKTexture *backgroundTexture = [SKTexture textureWithCGImage:backgroundCGImage];
SKSpriteNode *someNode = [SKSpriteNode spriteNodeWithTexture:backgroundTexture];
someNode.position = CGPointMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame));
[someNode setScale:0.5f];
[self addChild:someNode];
}
return self;
}
- (void)didMoveToView:(SKView *)view{
UISwipeGestureRecognizer *leftSwipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action: @selector(leftFlip:)];
[leftSwipe setDirection:UISwipeGestureRecognizerDirectionLeft];
[self.view addGestureRecognizer:leftSwipe];
}
- (void)leftFlip:(id)sender{
SKView * skView = (SKView *)self.view;
SKScene * scene = [Ep1Slide2 sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
[skView presentScene:scene transition:[SKTransition pushWithDirection:SKTransitionDirectionLeft duration:1.2]];
}