2

during the past one month I've made a huge advancement towards my first App on the App Store. It is a simple 2D Sprite Kit Game. However, with a release in sight, I am struggling with performance on an iPhone 4.

My game is usually showing around 20 Nodes at a time, while some of them have a physics body. Not much contact is happening, mostly just movement.

Recently I've added both iAd and AdMob banner support to my project. The banners are both setup and working. My game tries to show iAd if available and uses AdMob as a fallback.

Now that I purchased a developer membership and can finally test the app on actual devices, i experience many many frame drop and generally low fps on iPhone 4. iPhone 5 and iPhone 4S seem to be working fine but iPhone 4 averages at about 40fps with drops to 15/20 fps. I have also tested the game without Ads and that improves the framerate by a significant amount and reduces lags, but they are still there on iPhone 4.

Whenever the game scene is presented, I initiate both iAd- and AdMob-banner and have them request a banner. If iAd succeeds, that one is displayed, if not, AdMob's banner is moved to the visible area. This is how they are initiated:

    iADBanner = [[MyIADBannerView alloc] initWithAdType:ADAdTypeBanner origin:CGPointMake(0, -CGSizeFromGADAdSize(kGADAdSizeBanner).height)];
    iADBanner.delegate = self;
    [iADBanner moveToOrigin];
    [self.view addSubview:iADBanner];

    [GADBanner moveToOrigin];
    GADBanner = [[MyGADBannerView alloc] initWithAdSize:kGADAdSizeBanner origin:CGPointMake(0, -CGSizeFromGADAdSize(kGADAdSizeBanner).height)];
    GADBanner.rootViewController = self;
    GADBanner.delegate = self;
    [GADBanner moveToOrigin];
    GADRequest* request = [GADRequest request];
    request.testDevices = [NSArray arrayWithObjects:GAD_SIMULATOR_ID, @"device_id", nil];  
    [GADBanner loadRequest:request];
    [self.view addSubview:GADBanner];

I don't really know what is causing the lags but am somehow disappointed, because a simple 2D-game with about 20 nodes shouldn't have any performance issues, even on iPhone 4, should it?

Maybe you can give me some suggestions on how to optimize my SpriteKit-code.

Thanks in advance

lerei
  • 133
  • 5
  • Are those 20 nodes animated ? Are you constantly creating new nodes possibly and deleting old ones ? – prototypical Aug 22 '14 at 18:55
  • You need to narrow down your performance issues. It's impossible to give anything but vague or general suggestions at this point. – sangony Aug 22 '14 at 19:14
  • 1
    iphone 4 is comparatively slow, even slower than the 3gs as it has to render 4x the number of pixels with only a 33% speed bump. As for iad performance this has been reported many times before: search SO. – CodeSmile Aug 22 '14 at 20:12

1 Answers1

0

Most of them have some SKActions (movement only) running on them, while only a few have PhysicsBodies and perform physics stuff... As soon as they leave the screen, the nodes are being removed from their parent.

I think I'll continue my project first and then look at performance improvements some time later. However, what I was also trying to learn is are there some techniques that should always be used in order to improve general performance?