开发者

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];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜