Android 顺序发牌动画
/*八副牌动画*/ ImageView[][] washCards = new ImageView[8][3]; Animation upIn = AnimationUtils.loadAnimation(Game_Baccarat.this, R.anim.poker_up_in); binding.ibtStart.setOnClickListener(new View.OnClickListener() {//点击开始洗牌切牌 @Override public void onClick(View v) { for (int i = 0; i < washCards.length; i++) { System.out.println("二维数组长度:"+washCards.length); for (int j = 0; j < 3; j++) { washCards[i][j]= new ImageView(Game_Baccarat.this); washCards[i][j].setImageResource(R.drawable.poker0_0); washCards[i][j].setX(positions[8].getX()); washCards[i][j].setY(-300); washCards[i][j].setLayoutParams(new ViewGroup.LayoutParams(140, 200)); binding.getRoot().addView(washCards[i][j]); washCards[i][j].startAnimation(upIn); @SuppressLint("Recycle") ObjectAnimator transXS = ObjectAnimator.ofFloat(washCards[i][j], "translationX", positions[i+1].getX()-j*7); @SuppressLint("Recycle") ObjectAnimator transYS = ObjectAnimator.ofFloat(washCards[i][j], "translationY", positions[i+1].getY()); @SuppressLint("Recycle") ObjectAnimator rotationS = ObjectAnimator.ofFloat(washCards[i][j], "rotation", 0f, 360f); @SuppressLint("Recycle") ObjectAnimator scaleXS = ObjectAnimator.ofFloat(washCards[i][j], "scaleX", 1f, 1.5f); @SuppressLint("Recycle") ObjectAnimator scaleYS = ObjectAnimator.ofFloat(washCards[i][j], "scaleY", 1f, 1.5f); @SuppressLint("Recycle") AnimatorSet sendSet = new AnimatorSet(); sendSet.setDuration(1000); sendSet.playTogether(transXS, transYS, rotationS,scaleXS,scaleYS); sendSet.setStartDelay(500 *(i+1));//关键代码,设置不同延时,使牌顺序发出 sendSet.start(); } } } });
播放动画时设置不同延时,使牌顺序发出:
sendSet.setStartDelay(500 *(i+1));//关键代码,设置不同延时,使牌顺序发出
以前的是程序员的老板,现在是末路出家的程序员小白。