0

Xcode 4.3.2 でゲームを開発しています

ゲーム内では、この関数を頻繁に呼び出して、アニメーション付きの画面に 2 つの画像を追加する必要があります。最初の画像は左から、2 番目は右から、2 秒後にオフになります。

-(void) PandaAnimation2 {
[pandablock3 removeFromSuperview];
[awesomeview removeFromSuperview];

//pandablock3 is a UIImageView
//awesomeview is a UIImageView
pandablock3.frame = CGRectMake(400, 101, 111, 208);
awesomeview.frame = CGRectMake(-400, 9, 230, 68);

[self addSubview:pandablock3];
[self addSubview:awesomeview];


[UIImageView beginAnimations:@"movein" context:NULL];
[UIImageView setAnimationBeginsFromCurrentState:YES];
[UIImageView setAnimationDelegate:self];
[UIImageView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIImageView setAnimationDuration:2.0];

pandablock3.frame = CGRectMake(208, 101, 111, 208);
awesomeview.frame = CGRectMake(11, 9, 230, 68);

[UIImageView commitAnimations];

[UIImageView beginAnimations:@"moveout" context:NULL];
[UIImageView setAnimationDelay:2.0];
[UIImageView setAnimationBeginsFromCurrentState:YES];
[UIImageView setAnimationDelegate:self];
[UIImageView setAnimationDuration:1.0];
[UIImageView setAnimationCurve:UIViewAnimationCurveEaseOut];

pandablock3.frame = CGRectMake(400, 101, 111, 208);
awesomeview.frame = CGRectMake(-400, 9, 230, 68);
[UIImageView commitAnimations];

}

それはうまくいきますが、一度だけです!なんで?

助けてください!

4

1 に答える 1

0

あなたのコードを呼び出しているものを見ずに言うのは難しいですが、私の推測ではpandablock3awesomeview最初の呼び出しの後に解放され、したがってnil2 番目の呼び出しになります。

于 2012-06-05T20:11:05.387 に答える