android 线程意义,Android LunarLander LunarView new一个线程的意义何在

这两天重写了sample下面的LunarLander代码,忽然不明白为啥在 LunarView 下面要自己new一个线程来处理呢?既然都是通过while(true){}来画图,那直接在SurfaceView里面搞个循环有啥不可?

对比自己写的一个俄罗斯方块,就是直接继承了SurfaceView,通过Handler做动画处理,没觉得需要new一个线程来处理。

有人能指点迷津或者一起讨论讨论...

Java代码

/**

* View that draws, takes keystrokes, etc. for a simple LunarLander game.

*

* Has a mode which RUNNING, PAUSED, etc. Has a x, y, dx, dy, ... capturing the

* current ship physics. All x/y etc. are measured with (0,0) at the lower left.

* updatePhysics() advances the physics based on realtime. draw() renders the

* ship, and does an invalidate() to prompt another draw() as soon as possible

* by the system.

*/

class LunarView extends SurfaceView implements SurfaceHolder.Callback {

class LunarThread extends Thread {

.........

......

...

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值