0

AnimationDrawableを使用して6つの画像を表示しました。アニメーション化に成功しました。

しかし、それは同じ場所をアニメートするだけです。

しかし、次のフレームが表示されているときに前に進む必要があります。どうすれば表示できますか。

私のコードは。、

<?xml version="1.0" encoding="utf-8"?><animation-list xmlns:android="http://schemas.android.com/apk/res/android"   android:oneshot="false">
<item android:drawable="@drawable/frog" android:duration="50" />
<item android:drawable="@drawable/frog1" android:duration="50" />
<item android:drawable="@drawable/frog2" android:duration="50" />
<item android:drawable="@drawable/frog3" android:duration="50" />
<item android:drawable="@drawable/frog4" android:duration="50" />
<item android:drawable="@drawable/frog5" android:duration="50" /> </animation-list> 




private void animate() {
        ImageView imgView = (ImageView) findViewById(R.id.animationImage);
        // imgView.setVisibility(ImageView.VISIBLE);
        imgView.setBackgroundResource(R.drawable.ani);


        AnimationDrawable frameAnimation = (AnimationDrawable) imgView
                    .getBackground();

        if (frameAnimation.isRunning()) {
              frameAnimation.stop();
              b.setText("Start");

        } else {
              frameAnimation.start();
              b.setText("Stop");
        }
  }

次のフレームを表示すると、前方に移動します。plsは私を助けます。

4

1 に答える 1

0

http://obviam.net/index.php/sprite-animation-with-android/ コードを変更して場所を移動し、写真が別の場所にあるようにする必要があると思います

ソースを実行すると、最後の写真が必要であることがわかります。写真を通して同じですが、それは緑のマスクを実行します移動します。緑の効果はあなたの必要性です

于 2012-04-09T08:44:54.020 に答える