ios - How to detect collision between UIImageViews? -
ios - How to detect collision between UIImageViews? -
i'm building game, in want observe collision between uiimageviews, adding uiimageviews in array , there image of ball bouncing around screen. i'm not able observe collision between uiimageviews added in array(self.myviews) , uiimageview of ball added in storyboard. can't figure out problem.
- (void) performanimation { int widht; int heigh; (uiview * obj in self.myviews){ [obj removefromsuperview]; } [self.myviews addobject:self.ball]; [self.view addsubview: self.ball]; (heigh = 30; heigh < 200; heigh = heigh + 40) { (widht = 35; widht < 300; widht = widht + 40) { uiimageview *image0 =[[uiimageview alloc] initwithframe:cgrectmake(widht,heigh,20,10)]; image0.image=[uiimage imagenamed:@"gruener-balken.png"]; [self.view addsubview:image0]; [self.myviews addobject:image0]; } } } - (void)ballmovement { (uiimageview *obj in self.myviews) { if (cgrectintersectsrect(obj.frame, _ball.frame)) { //something happens here } } }
i want create uiimageviews dynamically , add together them mutable array (myviews). want observe collision between uiimageviews in array , imageview created in storyboard (_ball.frame). problem is, no collision detected, , ball moves behind image views loop.
ios objective-c
Comments
Post a Comment