我是新來的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)。另外請記住,這裏需要正確的語法和代碼格式,而且這不是一個編碼器僱用網站。 –