我是新来的iPhone编程,我目前正在研究ballsplit游戏。在这场比赛中,当我的子弹击中任何球时,我希望它创造出两个新球。我的子弹和球都是uiimageview。CGRect与多个CGRect碰撞
这里是我的代码:
if ((CGRectIntersectsRect(bullet.frame,Ball.frame)) && !(ball)){
ball=TRUE;
x=Ball.frame.origin.x;
y=Ball.frame.origin.y;
[self performSelector:@selector(createball)];
}
这里是我创造球功能..
-(void)createball{
if (ball) {
imageMove1 = [[UIImageView alloc] initWithFrame:CGRectMake(x,y,50 ,50)];
UIImage *imag = [UIImage imageNamed:@"ball1.png"];
[imageMove1 setImage:imag];
[self.view addSubview:imageMove1];
[ballArray addObject:imageMove1];
imageMove2 = [[UIImageView alloc] initWithFrame:CGRectMake(x,y,50 ,50)];
UIImage *imag1 = [UIImage imageNamed:@"ball1.png"];
[imageMove2 setImage:imag1];
[self.view addSubview:imageMove2];
[ballArray addObject:imageMove2];
ball=FALSE;
[self performSelector:@selector(moveball)];
}
}
现在创建这两个uiimgeview,当子弹击中了这两个的UIImageView之一后,我希望它再创建两个uiimageviews。但是,我面对怎样才能得到这些新的UIImageView的框架问题...
欢迎来到StackOverflow。由于您是新手,请记得阅读[FAQ](http://stackoverflow.com/faq)。另外请记住,这里需要正确的语法和代码格式,而且这不是一个编码器雇用网站。 –