Objective-C for iPhone は初めてなので、実験を行っています。
画面上で動く2つの四角形を作る場合、違いがないように見える2つの方法を試しました。しかし、私はそれがより重いグラフィックスである可能性があると思います.
どちらのメソッドもタイマーで更新されます。
[NSTimer scheduledTimerWithTimeInterval:1.0/60.0 target:self selector:@selector(update) userInfo:nil repeats:YES];
1-移動
最初に試した方法は、更新メソッドで正方形の UIView の中心点を移動することです。
mySquare.center = CGPointMake(mySquare.center.x+0.5, mySquare.center.y+0.5);
2-描画
2 番目の方法は、正方形の UIView のフレーム プロパティを変更し、更新メソッドでビューを再描画します。
[mySquare update:CGRectMake(mySquare.frame.origin.x+0.5, mySquare.frame.origin.y+0.5, mySquare.frame.size.width, mySquare.frame.size.height)];
Square UIView 更新メソッドでは:
[self setFrame:rect];
[self setNeedsDisplay];
だから、移動と描画の間。
Objective-C で物事を動かすには何が最適でしょうか? 最高のパフォーマンスを発揮するのは何ですか?ベストプラクティスは何ですか?
ありがとう
ロム