このコードの目的は、オブジェクトを自動的に作成し、アニメーション化して画面上を移動することです。120 で x に達すると、削除されます。私が直面している問題は、フレームを取得できず、配列内のオブジェクトから x 値が取得できないことです。ここに私のコードがあります、何か提案はありますか?
- (void)AddRight{
Bullets= [[NSMutableArray alloc] init];
CGRect frame = CGRectMake(480, 180, 60, 55);
Bullets = [[UIImageView alloc] initWithFrame:frame];
Bullets.image=[UIImage imageNamed:@"Bullet.png"];
[self.view addSubview:Bullets];
[Bullets addObject:theBullet];
for (int x = 0; x < [Bullets count]; x++) {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.5];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationDelegate:self];
[theBullet setFrame:CGRectMake(265, 180, 60, 55)];
[UIView commitAnimations];
}
検出は次のとおりです。
for (int x = 0; x < [Bullets count]; x++) {
NSObject *bull = [[LeftBees objectAtIndex:x]];
CGRect frame = bull.frame;
if (frame.origin.x>120) {
[bull removeFromSuperview];
}
}
「CGRect フレーム = referal.frame;」「プロパティフレームはNSObjectの一部ではありません」というエラーがあります