학교에서 공부중에 있는데 원낙 얇고 넓게 배우는터라 막히네요 ... 부루마블을 만들려고 생각하는데 주사위 굴리는는 해결됬는데 이동을 못시겠어요 ... 트윈애니매이션 말고 다른거 있음 말씀좀 해주세요 부탁드리겠습니다 ㅠㅠ
public class Pan_Activity extends Activity implements OnClickListener{
Button btn_dice;
ImageView player;
LinearLayout dicepan;
AnimationDrawable mAni;
int nR;
TranslateAnimation Tans;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Window win = getWindow();
win.requestFeature(Window.FEATURE_NO_TITLE);
win.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.pan);
btn_dice = (Button)findViewById(R.id.btn_dice);
player = (ImageView)findViewById(R.id.image_play);
dicepan = (LinearLayout)findViewById(R.id.LinearLayout1);
final ImageView dice1 = (ImageView)findViewById(R.id.dice1);
ImageView dice2 = (ImageView)findViewById(R.id.dice2);
setImage(dice1);
setImage(dice2);
nR = new Random().nextInt(11)+1;
btn_dice.setOnClickListener(this);
}
public void setImage(ImageView dice)
{
if(nR == 0)
dice.setImageResource(R.drawable.d1);
else if(nR == 1)
dice.setImageResource(R.drawable.d2);
else if(nR == 2)
dice.setImageResource(R.drawable.d3);
else if(nR == 3)
dice.setImageResource(R.drawable.d4);
else if(nR == 4)
dice.setImageResource(R.drawable.d5);
else if(nR == 5)
dice.setImageResource(R.drawable.d6);
}
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Animation anim = null;
switch (arg0.getId()) {
case R.id.btn_dice:
if(nR == 2){
anim = new TranslateAnimation(0, -200, 0, 0);
}else if (nR == 3) {
anim = new TranslateAnimation(0, -300, 0, 0);
}else if (nR == 4) {
anim = new TranslateAnimation(0, -400, 0, 0);
}else if (nR == 5) {
anim = new TranslateAnimation(0, -500, 0, 0);
}else if (nR == 6) {
anim = new TranslateAnimation(0, -600, 0, 0);
}else if (nR == 7) {
anim = new TranslateAnimation(0, -700, 0, 0);
}else if (nR == 8) {
anim = new TranslateAnimation(0, -800, 0, 0);
}else if (nR == 9) {
anim = new TranslateAnimation(0, -900, 0, 0);
}else if (nR == 10) {
anim = new TranslateAnimation(0, -1000, 0, 0);
}else if (nR == 11) {
anim = new TranslateAnimation(0, -1100, 0, 0);
}else if (nR == 12) {
anim = new TranslateAnimation(0, -1200, 0, 0);
}
break;
}
anim.setFillAfter(true);
anim.setDuration(1000);
player.startAnimation(anim);
}
}