0

i've display six images using AnimationDrawable. It was successfully animated.

But it only animate same place.

But i need move forward when next frame is showing. How can i show it.

My code is.,

<?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");
        }
  }

When showing the next frame, it move forward location. Pls help me.

didxga
  • 5,935
  • 4
  • 43
  • 58
RVG
  • 3,538
  • 4
  • 37
  • 64

1 Answers1

0

i think you should http://obviam.net/index.php/sprite-animation-with-android/ you can modify the code and move the location so that the pic at difference place

if you run the source ,you will see the last pic is your need. through the pic is the same,but it run a green mask is move.the green effect is your need

pengwang
  • 19,536
  • 34
  • 119
  • 168