how can I recall a part of body in a method that would call after each second?
I am coding as follows
-(void) moveMetho开发者_运维知识库d :(Paddle *) pad {
float counter = 10;
self.position = CGPointMake(80,counter);
}
Now I want increase counter with +5 after each one second, what should I do, so that object should move upside?
You could use below by declaring counter as static variable.
-(void) moveMethod :(id) sender {
static float counter = 10;
self.position = CGPointMake(80,counter);
counter+=5;
}
Here is the timer
[NSTimer scheduledTimerWithTimeInterval:1.0f
target:self
selector:@selector(moveMethod:)
userInfo:nil
repeats:YES];
精彩评论