I have found 2 bugs in LunarLander. First of all, a new thread should
be created before calling thread.start() method. The method start()
throws IllegalThreadStateException if it is invoked twice with the
same thread. In addition, we should check whether the canvas object is
null before calling doDraw(c). I suggested a solution in a class,
which may be useful for developers: 
http://code.google.com/p/android/issues/detail?id=23416
You can download it and use it.

Aleksander Dobrowolski

On Dec 26 2011, 4:04 pm, Peter Webb <r.peter.w...@gmail.com> wrote:
> Both LunarLander and JetBoy in the SDK demos have the bug that they
> don't handle you pressing the home button in the app - when you
> restart the application, it says "application stopped unexpectedly".
> These both run render/update in a separate thread, which appears to
> not be terminated.
>
> Snake handles home and back buttons quite well. It has a different
> structure, it is single threaded. I can simply change the
> thread.sleep() to be zero, and use it to implement my game engine in a
> single thread. But it actually draws the screen using a
> View.invalidate() call, which I have heard is slow, and my app is real
> time.
>
> So:
>
> 1. Is View.Invalidate() as used by Snake slower than the approach of
> locking the surface used by LunarLander and JetBoy, slower enough for
> me to care?
>
> 2. Can anybody suggest any game samples which correctly implement
> system events like the user hitting the home or back button? Many on
> the web are obviously derived from LunarLander or JetBoy and have the
> same problem.
>
> Peter Webb

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to