我想知道如何随着时间的推移增加间隔,以便我可以添加目标。我还是cocos2d的新手。
[self schedule:@selector(gameLogic:) interval:0.7];
-(void)gameLogic:(ccTime)dt {
[self addTarget];
}
答案 0 :(得分:2)
为什么不声明一个简单的属性(int,float等)来保存调用方法的次数,并在调用方法本身时递增它?这样,它只是一个乘法问题:
//.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_++;
}
答案 1 :(得分:1)
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
}