0
を停止し、私はhttp://www.youtube.com/watch?v=rD3MTTPaK98 を行うと、ここに私のコードですたいものです:アニメーションはここ
-(void) onTimer {
UIImage * image = [UIImage imageNamed:@"abouffer_03.png"];
imageView = [[UIImageView alloc] initWithImage:image];
[imageView setCenter:[self randomPointSquare]];
[imageViewArray addObject:imageView];
[[self view] addSubview:imageView];
[imageView release];
ix=imageView.center.x;
iy=imageView.center.y;
X=(240-ix)/230;
Y=(160-iy)/230;
coteA=(240-ix);
coteB=(160-iy);
angleDeRotation=atan(coteB/coteA);
if(ix>250||0>iy>320){
imageView.transform = CGAffineTransformMakeRotation(angleDeRotation+3.14);
}
else{
imageView.transform = CGAffineTransformMakeRotation(angleDeRotation);
}
}
-(void)onTimer2{
for(int i=0; i< [imageViewArray count];i++){
imageView = [imageViewArray objectAtIndex:i];
imageView.center = CGPointMake(imageView.center.x + X, imageView.center.y + Y);
}
にOnTimer 2秒ごと と呼ばれているが、それは動作しません、エラーはありませんが、とき " 2秒後に「imageView」が作成され、移動して、作成された新しい「imageView」と同じ方向に移動します。これをどうすれば解決できますか?私のフランス語には申し訳ありません:/
私はコードで私を見せてください本当に理解できませんか? –
この行を見てください: 'imageView.center = CGPointMake(imageView.center.x + X、imageView.center.y + Y);' XとYはどこから来たのですか? '-onTimer'メソッドです。しかし、XとYはそれぞれ1つしかないので、設定するたびに前の値を上書きします。 –
私は何をすべきかを示す答えを編集しています。 –