我是Android的新手,我正在制作老虎机游戏,但无法弄清楚如何开始使用插槽的动画。现在我正在尝试使用3个不同的png文件一次又一次地切换滚动动画,并且logcat说明了一些关于帧跳过的内容。它只是没有改变图像。抱歉我的英文。
方法代码:
public void animation(){ imageView1.setImageResource(R.drawable.slot1); imageView2.setImageResource(R.drawable.slot2); imageView3.setImageResource(R.drawable.slot3); android.os.SystemClock.sleep(70); imageView1.setImageResource(R.drawable.slot2); imageView2.setImageResource(R.drawable.slot3); imageView3.setImageResource(R.drawable.slot1); android.os.SystemClock.sleep(70); imageView1.setImageResource(R.drawable.slot3); imageView2.setImageResource(R.drawable.slot1); imageView3.setImageResource(R.drawable.slot2); android.os.SystemClock.sleep(70); imageView1.setImageResource(R.drawable.slot1); imageView2.setImageResource(R.drawable.slot2); imageView3.setImageResource(R.drawable.slot3); android.os.SystemClock.sleep(70); imageView1.setImageResource(R.drawable.slot2); imageView2.setImageResource(R.drawable.slot3); imageView3.setImageResource(R.drawable.slot1); android.os.SystemClock.sleep(70); imageView1.setImageResource(R.drawable.slot3); imageView2.setImageResource(R.drawable.slot1); imageView3.setImageResource(R.drawable.slot2); android.os.SystemClock.sleep(70); imageView1.setImageResource(R.drawable.slot1); imageView2.setImageResource(R.drawable.slot2); imageView3.setImageResource(R.drawable.slot3); android.os.SystemClock.sleep(70); imageView1.setImageResource(R.drawable.slot2); imageView2.setImageResource(R.drawable.slot3); imageView3.setImageResource(R.drawable.slot1); android.os.SystemClock.sleep(70); imageView1.setImageResource(R.drawable.slot3); imageView2.setImageResource(R.drawable.slot1); imageView3.setImageResource(R.drawable.slot2); android.os.SystemClock.sleep(70); imageView1.setImageResource(R.drawable.slot1); imageView2.setImageResource(R.drawable.slot2); imageView3.setImageResource(R.drawable.slot3); android.os.SystemClock.sleep(70); }
logcat的:
05-08 17:06:53.230:I / Choreographer(943):跳过74帧!该 应用程序可能在其主线程上做了太多工作。
答案 0 :(得分:0)
您正在主UI线程上调用sleep,您需要从单独的线程或AsyncTask运行此代码。