开发者

problem with the counter of a collision between two images

开发者 https://www.devze.com 2023-03-17 04:42 出处:网络
here is my code : -(void)collision { if(CGRectIntersectsRect(imageView.frame,centre.frame)){ [imageView removeFromSuperview];

here is my code :

-(void)collision {

    if(CGRectIntersectsRect(imageView.frame,centre.frame)){

        [imageView removeFromSuperview];
        count++;
        label.text= [NSString stringWithFormat:@"%d", count];
    }
}


- (void)viewDidLoad {
    [super viewDidLoad];

    [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(collision) userInfo:nil repeats:YES];

   开发者_运维问答 count=0;    
    scale=1;
}

with this code my count increase of more than one sometimes 34 and sometime 74 or 70 , why ?


Stops the receiver from ever firing again and requests its removal from its run loop.

 - (void)invalidate

class reference

helpful question

0

精彩评论

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