ゲームプロジェクトでRotateAnimation
とTranslateAnimation
を使用しています。回転を完了した後、TranslateAnimationを使用してイメージを次に保存します。それは正常に動作しますが、画像の回転が完了すると、一度画像が点滅します。アンドロイドのアニメーション?
public void Trainplace(int x,int y,Bitmap b){
param.setMargins(x, y, 0, 0);
Train.setLayoutParams(param);
Train.setImageBitmap(b);
Train.setVisibility(0);
}
public void Trainmove(int x){
TAnimation=new TranslateAnimation(0, 0, 0,x);
TAnimation.setInterpolator(new LinearInterpolator());
TAnimation.setDuration(2000);
TAnimation.setFillAfter(true);
//TAnimation.setFillBefore(true);
Train.startAnimation(TAnimation);
}
public void Trainrotate(int a,int b,int c,int d){
RAnimation=new RotateAnimation(a,b,c,d);
RAnimation.setInterpolator(new LinearInterpolator());
RAnimation.setDuration(2000);
RAnimation.setFillAfter(true);
Train.startAnimation(RAnimation);
}
public void onClick(View v) {
switch (v.getId()) {
case R.id.b:
Trainplace(20, 255,bmpy1);
Trainrotate(0,90,50,25);
//Stop button clicks
//B.setEnabled(false);
break;
case R.id.b2:
Trainplace(35, 230,bmpx1);
Trainrotate(0,-90,20,-30);
RAnimation.setAnimationListener(new AnimationListener() {
public void onAnimationStart(Animation arg0) {
}
public void onAnimationRepeat(Animation arg0) {
}
public void onAnimationEnd(Animation arg0) {
int p=0;
while(p<=1){
if(RAnimation.hasEnded()){
Toast.makeText(getApplicationContext(), "End", Toast.LENGTH_SHORT).show();
p=2;
}
}
Trainplace(85, 170,bmpy1);
Trainmove(-100);
}
});
break;
私の問題はrotateanimationを完了している - 現在の画像を別の画像に置き換えられます(。例:私の列車の画像は、IMがその場所に画像を90度回転を置き、その後90度回転)し、その後Translateanimationを使用することによって前進これは機能しています。
Rotateanimationを完了した後、Translateanimationを開始する前に、列車イメージが一度点滅します。
同じ画像は、問題なしで配置されます(アニメーションを回転に変換することを意味します)。
私の問題は、現在の画像を別の画像で置き換えた回転アニメーションをcopletingしていることです(例:私の列車の画像を90度回転させてから90度回転した画像をその場所に置いています)。そしてTranslateanimationを使って前進します。は働いている。私の問題は、Rotateanimationの完了後に画像を配置することです。そして、Translateanimationを開始する前に、列車の画像が一度点滅します。同じ画像は、noproblem(RotateanimationへのTranslateanimationを意味します)を置きます。私に答えてください.......... – venkat