0

写真を入れてアニメーション化する必要がある写真フレームがあります。背景がフレームになり、写真が前景画像になるimageViewを使用します。額縁が画面の上から真ん中に落ちて、その上にリボンが付いているような形で見せなければなりません。中央にドロップされた後、リボンが固定されて動かない間、画像のあるフレームのみが toFro モーションを実行します。どうやってそんなアニメを作るの?

ありがとう

4

2 に答える 2

1

Activity クラスでこれらの変数を宣言します

private ImageView myFrameAnimation;
private int iFrameCount;
private ImageView myPhotoLayer;

onStart またはボタン クリック イベントを使用してアニメーションを開始します。

@Override
protected void onStart() {
    super.onStart();
    Thread thr1 = new Thread(r1);
    thr1.start();
}

次に、アニメーションを実行する新しいスレッドを作成します

Runnable r1 = new Runnable() {
    public void run() {
    while (iFrameCount< 747) {

        runOnUiThread(new Runnable() {
            public void run() {
                iFrameCount++;
                switch (iFrameCount) {
                    //you can use a separate procedure here to move the ImageView with your picture in time with your animation
                    //the x,y cordinates ‎l depend on your screen/View size measured from top left corner. 
                case 310: animate_object(330,215,310,215,1);
                case 315: animate_object(150,380,150,420,80);
                case 320: animate_object(80,150,80,120,100);
                }

                   //store your animation images in the drawables folder with the name like img1.png, img2.png etc.     
                String image="img" + iFrameCount;
                resID = getResources().getIdentifier(image, "drawable",  getPackageName()); 
                if (resID != 0){

                    //Use these to time how long it takes to update the imageview/ Set your thread.sleep to around this time.
                    //startTime = System.currentTimeMillis();                           
                 myFrameAnimation.setImageResource(resID);
                    //endTime = System.currentTimeMillis();
                    //Log.d("Frame: " +iFrameCount + " setBackground took: " + (endTime - startTime) + " milliseconds");

                } else {
                           //we can skip frames if they are duplicates of the frame before to save space and memory and increase speed
                     //Log.d(TAG, "File skipped: " + iFrameCount);
                }
             }
           });
        try {
           Thread.sleep(43); //43 is milliseconds to give around 23 frames per second speed will depend on your image size that you are animating.
        } catch (InterruptedException iex) {}
      }           
      //Log.d(TAG, "Finished all frames");
      finish();
   }
};

そして最後に、額縁と一緒に写真をアニメーション化する手順があります

public void animate_object(int startx, int starty, int endx, int endy, int duration)
{
//photoLayer is the Id of your imageView holding the photo. You would need to have previously loaded your photo into the imageview using
//something like this myPhotoLayer.setImageResource(resID); before the animation is started.

    myPhotoLayer = (ImageView) findViewById(R.id.photoLayer); 
    TranslateAnimation move = new TranslateAnimation(startx, endx, starty, endy);
    move.setDuration(duration);
    move.setFillAfter(true);
    myPhotoLayer.startAnimation(move);
}
于 2012-11-28T02:15:28.083 に答える
0

あなたはそれを漫画のように描く必要があるでしょう。最初にビデオを撮って必要な動きを取得してから、(Adobe After Effectsを使用して)PNGシーケンスを作成し、ガイドとして必要なフレームを取得してから、IllustratorまたはPhotoshopで再描画してください。

次に、animation.drawableを使用してアニメーションを作成し、フレームが多すぎない限り、フレームを表示します。

于 2012-11-24T22:36:46.157 に答える