第二个NSTimer没有调用void动作

时间:2014-12-17 14:54:09

标签: ios sprite-kit nstimer

if ([contact.bodyA.node.name  isEqualToString:@"growCoins"] || [contact.bodyB.node.name  isEqualToString:@"growCoins"]) {
        [hero grow];
        self.immune = YES;
        [self immuned];
        immunitytobeFading = [NSTimer timerWithTimeInterval:7 target:self selector:@selector(immunityFading) userInfo:nil repeats:NO];
        ////
        NSTimer *immunityFades;
        immunityFades = [NSTimer timerWithTimeInterval:3 target:self selector:@selector(immunityFaded) userInfo:nil repeats:NO];
        ////
     }
//BELOW IS NOT GETTING CALLED
-(void)immunityFaded
{
    self.immune = NO;
    NSLog(@"no longer immune");
}
//BELOW IS GETTING CALLED FINE
-(void)immunityFading
{
    ...
    [self addChild:plusone];
    [self animateWithPusleFading:plusone];
}

有人能想到第二个NSTimer没有被调用的原因吗? 我在NStimer上的IF语句中休息了一下它就打破了,但当我把Break放在-(void)immunityFaded上时它根本没有?

1 个答案:

答案 0 :(得分:0)

immunitytobeFading在其他地方定义,可能具有强大的参考价值。

immunityFades仅在方法的生命周期中定义。