Reputation: 17
I was wondering on how do I increase the interval over time so I can add target. I am still new to cocos2d.
[self schedule:@selector(gameLogic:) interval:0.7];
-(void)gameLogic:(ccTime)dt {
[self addTarget];
}
Upvotes: 0
Views: 323
Reputation: 19922
float interval = .7;
-(id)init{
...
[self scheduleOnce:@selector(gameLogic:) delay:interval]; //Check the name of the method, I'm not 100% sure about it
...
}
-(void)gameLogic:(ccTime)dt {
[self addTarget];
interval += dt; //Or whatever you want to increase it by
[self scheduleOnce:@selector(gameLogic:) delay:interval]; //Check the name of the method, I'm not 100% sure about it
}
Upvotes: 1
Reputation: 43330
Why not declare a simple property (int, float, etc.) to hold the number of times your method has been called, and increment it when you call the method itself? That way, it's just a multiplication problem:
//.h
...
@property (nonatomic, assign) int iterations;
//.m
@synthesize iterations = iterations_;
[self schedule:@selector(gameLogic:) interval:0.7*iterations_];
-(void)gameLogic:(ccTime)dt {
[self addTarget];
iterations_++;
}
Upvotes: 2