Search code examples
objective-csprite-kitskaction

Spritekit animation doesn't work in iOS7 but does in iOS8


I made a game to teach kids how to count. When you tap the right number it explodes and the next one starts to have a glowing animation as a tip.

A while ago I noticed that this specific animation doesn't work in iOS7.

This is how it looks like: animation

I made this with a NSTimer, that and a method with the animation:

-(void)addGlow
{
    if (!timer) {
        [self startTimer];
    }
    SKSpriteNode* back = [SKSpriteNode spriteNodeWithTexture:self.body.texture];
    back.blendMode = SKBlendModeAdd;
    back.position = CGPointMake(0, 0 - 2);
    [back runAction:[SKAction scaleTo:0.72 duration:0] completion:nil];
    SKAction* group = [SKAction group:@[[SKAction scaleTo:1 duration:0.8],[SKAction fadeAlphaTo:0 duration:0.8]]];
    [self addChild:back];
    [back runAction:[SKAction sequence:@[group,[SKAction removeFromParent]]]];
}

And this is my start method:

-(void)startTimer
{
    timer = [NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(addGlow) userInfo:nil repeats:YES];
}

I did debug it, and the method is called with no errors on both iOS versions. Any ideas of how can I discovery what is going on?


Solution

  • I see you're not setting zPosition. Make sure it contains what you expect. Apple made changes to the responder chain between iOS 7 and 8 so I wouldn't be surprised if they had changed how zPositions are initialised.