简体   繁体   English

如何使用多个线程在Surfaceview的画布上绘制多个位图?

[英]how to use multiple threads to draw multiple bitmaps on the canvas in surfaceview?

I am developing a game in which I have to show multiple image moving in directions but one image cannot over lap other how can i achieve this. 我正在开发一款游戏,其中我必须显示多个图像在方向上的移动,但是一个图像不能重叠,其他我该如何实现。 I think I should use multiple threads one thread for every image but when i try to initialize thread by sending it canvas using canvas it gives 我想我应该为每个图像使用多个线程,但是当我尝试通过使用canvas发送画布来初始化线程时,它给出了

error 01-11 17:18:15.409: E/AndroidRuntime(1046): java.lang.IllegalThreadStateException: Thread already started.

How can I achive this. 我怎么能做到这一点。 Can any body give me idea or some tutorial. 任何人都可以给我想法或一些教程。 Any help will be appreciable. 任何帮助将是可观的。

Your error happens when you try to start an already started thread. 当您尝试启动一个已经启动的线程时,会发生错误。 You don't need to have multiple threads. 您不需要有多个线程。 One thread for all your drawing is more than enough. 所有绘图仅需一根螺纹就足够了。

I have written a tutorial series for introduction into android 2d drawing. 我已经写了一个教程系列来介绍android 2d绘图。 I recommend you to start with the second part that introduce the thread usage . 我建议您从介绍线程用法第二部分开始。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM