アニメーションを使用して、 Ludo ボードで画像 (トークン) を下から上、左から右に変換したいだけです。このために、すべてのトークン(赤、青、黄、緑の色)が移動する場所からすべての ImageView の座標を取得しましたが、今は行き詰まっています。次に何をすればいいですか?私はAndroidアニメーションが初めてです。どうすればそれができますか?
これは私の配列インデックスコードです:
public void onCreate( Bundle savedInstanceState ) {
super.onCreate( savedInstanceState );
setContentView( R.layout.start );
double aPowersOfTwo[] = new double[60];
aPowersOfTwo[0]=Math.pow(81,263);
aPowersOfTwo[1]=Math.pow(50,262);
aPowersOfTwo[2]=Math.pow(50,231);
aPowersOfTwo[3]=Math.pow(80,227);
}
黄色のトークンの私のJavaコードは
switch(rand.nextInt(6) + 1)
{
case 1:
diceImage.setImageResource(R.drawable.dice_one);
yellowToken.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch(v.getId()){
case R.id.yellow_token9:
Animation animation = new TranslateAnimation(0,80,0,48);
animation.setDuration(1500);
animation.setFillAfter(true);
yellowToken.startAnimation(animation);
yellowToken.setVisibility(0);
break;
}
}});
case 2:
diceImage.setImageResource(R.drawable.dice_two);
Log.d("dice", "2");
break;
case 3:
diceImage.setImageResource(R.drawable.dice_three);
Log.d("dice", "3");
break;
case 4:
diceImage.setImageResource(R.drawable.dice_four);
Log.d("dice", "4");
break;
case 5:
diceImage.setImageResource(R.drawable.dice_five);
Log.d("dice", "5");
break;
case 6:
diceImage.setImageResource(R.drawable.dice_six);
yellowToken.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch(v.getId()){
case R.id.yellow_token9:
Animation animation = new TranslateAnimation(0,80,0,48);
animation.setDuration(1500);
animation.setFillAfter(true);
yellowToken.startAnimation(animation);
yellowToken.setVisibility(0);
break;
}
}});
私のxmlコードは
<ImageView
android:id="@+id/yellow_token9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="45dp"
android:layout_marginTop="222dp"
android:clickable="true"
android:background="@drawable/yellow"/>