newsTimer
fires every 35 seconds, but it runs runNews
2 times. I get the NSLog that I setup in runNews
2 times every time it fires.
-(id)init
{
if ([super init]) {
[self loadDefaults];
NSTimer *newsTimer = [NSTimer scheduledTimerWithTimeInterval:35.0 target:self selector:@selector(runNews) userInfo:nil repeats:YES];
}
return self;
}
-(void)runNews
{
NSMutableArray *headingArray;
if (_currentTips < 20) {
headingArray = [NSMutableArray arrayWithObjects:@"Text 1", @"Text 2",
}
int randomGen = arc4random_uniform(headingArray.count - 1.0);
NSString *headingString = [NSString stringWithString:headingArray[randomGen]];
headingLabel = [[CCLabelTTF alloc] initWithString:headingString fontName:@"Minecraftia-Regular.ttf" fontSize:12.0];
[headingLabel setPositionType:CCPositionTypeMake(CCPositionUnitPoints, CCPositionUnitPoints, CCPositionReferenceCornerTopRight)];
[headingLabel setPosition:ccp(-200, 38)];
[headingLabel setFontColor:([CCColor greenColor])];
[self addChild:headingLabel];
[headingLabel runAction:([CCActionMoveTo actionWithDuration:20.0 position:ccp(500, 38)])];
NSLog(@"Running news");
[headingLabel performSelector:@selector(removeFromParent) withObject:nil afterDelay:20.0];
}
I can't see any reason why this would run twice... Any ideas?