2012-02-27 16 views
0

私はiOSのグラフィックスとアニメーションが初めてで、下のビデオのように、フリック時に画像の運動量の回転をどのように達成するかを知りたいと思います。画像は素敵な揺れを持っていじっていないとしてもiOSでの運動量の回転

video

ありがとうございました。

+1

古い物理学のテキストブックを破棄することから始めよう。 –

+1

個人的には物理エンジンを使用します。最初は上に見えるかもしれませんが、自分自身で物理学を書いてくれます! –

+0

James、Chipmunkや別の物理エンジンを使用していますか? –

答えて

1

これはかなり滑らかです。これは、ポイント(頂点の中心)を中心にしてビューを回転させ、次にアルゴリズム的に回転するのに要する時間を変更し、必要に応じて反転させます。コードを教えることはできませんが、Hegarty教授のビデオデモを見ると、必要なツールが得られると思います。彼はビューの外側の点を中心に回転します。ビューの端を回転させるだけで(ビューを縮小しないでください)それをチェックアウト:

パート1:http://www.stanford.edu/class/cs193p/cgi-bin/drupal/node/291

パート2:http://www.stanford.edu/class/cs193p/cgi-bin/drupal/node/293

あなたは間違いなく、説明がたくさんあるとして、iTunesのU(無料)オフの動画をダウンロードすることをお勧めします。

幸運、

ダミアン

0

私はこれの著者でチェックし、それはBOX2D物理ライブラリを使用して実施されたことを知らされました。私はそのショットを与えるつもりです。回答ありがとう!

0
//this code can be used to rotate an image having both back and front 

    rotate = [UIButton buttonWithType:UIButtonTypeCustom]; 
     [rotate addTarget:self action:@selector(rotate1)forControlEvents:UIControlEventTouchDown]; 
     rotate.frame = CGRectMake(137.5, 245, 45, 46); 
     [rotate setBackgroundImage:[UIImage imageNamed:[NSString stringWithFormat:@"viewing.png"]] forState:UIControlStateNormal]; 
     [self.view addSubview:rotate]; 

    int count; 
    count=0; 

    -(void)rotate1 
    { 


     count=count+1; 
     NSLog(@"rotate"); 
     [UIView transitionWithView:imagecircle // use the forView: argument 
          duration:1   // use the setAnimationDuration: argument 
          options:UIViewAnimationOptionTransitionFlipFromLeft 
     // check UIViewAnimationOptions for what options you can use 
         animations:^{   // put the animation block here 
          imagecircle.image = imagecircle.image; 
         } 
         completion:NULL]; 

     if(count%2==0) 
     { 
      NSLog(@"image.str.%@",appDelegate.imageNameString); 
      [imagecircle setImage:[UIImage imageNamed:appDelegate.imageNameString]]; 
      [labellocation removeFromSuperview]; 
      [labeldate removeFromSuperview]; 
      [self.imagecircle addSubview:labelfrom]; 

     } 
     else 
     { 
      [imagecircle setImage:[UIImage imageNamed:@"TGP_BACK.png"]]; 
      [labelfrom removeFromSuperview]; 
      [self.imagecircle addSubview:labellocation]; 
      [self.imagecircle addSubview:labeldate]; 
     } 



    } 
関連する問題