0

Android で開発したいゲームのインターフェース用に私が行ったこのデザインを見てください: http://www.moboing.com/smallshow.jpg

ユーザーが風船に触れると、その星/グレアアニメーションが星を落として再生されるようにします。私が興味を持っているのは、Eclipse/Java でアプリを開発する際にそのアニメーションを可能にするための最良の一般的な方向性/アプローチです。

星のいくつかのバリエーションを透明なPNGとして作成し、タッチでアニメーション化することを考えていましたが、初心者なので完全にはわかりません.

4

1 に答える 1

1

一連の画像のようなアニメーションを作成し、AnimationDrawable クラスを使用してアニメーション化することができます。例を示しましょう。

ImageView my_image = (ImageView) findViewById(R.id.my_animation);
AnimationDrawable animation = new AnimationDrawable();

// We need to add each image to our final animation setting time interval between them
animation.addFrame(getResources().getDrawable(R.drawable.img_1), 200);
animation.addFrame(getResources().getDrawable(R.drawable.img_2), 200);
animation.addFrame(getResources().getDrawable(R.drawable.img_3), 200);

animation.setOneShot(false);

my_image.setBackgroundDrawable(animation);    // Set as background to see it
animation.start();    // Start playing the animation

どこ:

  • my_animation: ImageView を希望のレイアウトにします。
  • img_1img_2img_3: アニメーションを合成する画像 (作成してres/drawableフォルダーに保存する必要があります)。

それがあなたを助け、自分でそれを行う方法を描くことができることを願っています:)

PS:これは、必要なアクティビティのメソッドに含める必要があります(たとえば、onCreateユーザーの開始時に表示するために)。

于 2012-08-05T17:04:05.450 に答える