0

I'm creating a game that uses iOS Sprite Kit + particle emitter. It runs perfectly fine on my simulator, but when I run the game on my iphone 6, it's super slow and laggy and I can barely interact with it.

Any idea why the simulator is so different than my phone, and suggestions for how to fix it? Really appreciate any tips!

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
jbug123
  • 33
  • 6

1 Answers1

0

I am experiencing the same thing. Oddly enough, iPhone 5 and iPad performance is great. Usually 60fps.

On iPhone 6, it starts at 0-2 fps and usually stays there. Sometimes, after 20-30 seconds, it has completely buffered everything and I get 60fps. Usually, it never makes it there.

So it's not just the difference between Simulator and actual hardware. There is something very different (and wrong) about iPhone 6 and 6+.

By the way, I find it useful to create SKEmitterNodes with code, since it's faster for trying out different values. Here's a useful method for that:

- (SKEmitterNode *)buildEmitterWithImageName:(NSString *)imagefile {

    //instantiate explosion emitter
    SKEmitterNode *explosion = [[SKEmitterNode alloc] init];


    UIImage *image = [UIImage imageNamed:imagefile];

    [explosion setParticleTexture:[SKTexture textureWithImage:image]];
    [explosion setParticleColor:[UIColor whiteColor]];
    [explosion setParticleBirthRate:2];
    [explosion setNumParticlesToEmit:0];
    [explosion setParticleLifetime:3];
    [explosion setParticleLifetimeRange:1];
    [explosion setParticlePositionRange:CGVectorMake(60, 40)];

    [explosion setEmissionAngleRange:360];
    [explosion setParticleSpeed:80];
    [explosion setParticleSpeedRange:30];
    [explosion setXAcceleration:0.05];
    [explosion setYAcceleration:0.05];
    [explosion setParticleAlpha:1.0];
    [explosion setParticleAlphaRange:0];
    [explosion setParticleAlphaSpeed:0];
    [explosion setParticleScale:0.35];
    [explosion setParticleScaleRange:0.2];
    [explosion setParticleScaleSpeed:0];
    [explosion setParticleRotation:0];
    [explosion setParticleRotationRange:0];
    [explosion setParticleRotationSpeed:0];

    [explosion setParticleColorBlendFactor:0];
    [explosion setParticleColorBlendFactorRange:0];
    [explosion setParticleColorBlendFactorSpeed:0];
    [explosion setParticleBlendMode:SKBlendModeAlpha];

    return explosion;
}

In the code above, I was using birth rate of 2 and that was still a problem for iPhone 6.

--------- Updated with new information ----------

In my app, there is more than one view controller, since much of the app uses a standard navigation controller. Also, some of these view controllers had their own SKView and SKScene instances.

It was never a problem with iPhone 5 and iPad to do this, but it seems to be a killer for iPhone 6 and 6+. I did an experiment where I reduced the app to a single VC with the SKScene and SKEmitterNode that I was trying to animate. Suddenly, it works at 60fps.

FYI, I have 4 emitter nodes with different art assets running in this scene and it is super fast, as it should be.

Quite annoying that I have to re-architect the app just because of this.

Hugh
  • 443
  • 4
  • 11