I have been looking at a lot of tutorials and blogs about Android game development and I have a question regarding the best way to implement threads.
Some examples, like Lunar Lander, has an inherited SurfaceView class (LunarView) with another class inside (LunarThread) that seems to handle the updates and drawing to the SurfaceView.
Other examples I found on the net have a very basic thread that has a run() loop and calls update and开发者_如何学运维 draw methods that are coded in the inherited SurfaceView class. The update/draw methods in the SurfaceView class also calls update/draw methods in other classes for objects that are used in the game.
Each seem to work, but I am not sure which is the best way to proceed. I also can't get past having a class within a class for some reason. Is that normal?
Thanks for your help!
I think its not the best practice. LunarLander is created as a sample project to give some idea of how to use SurfaceView. But again if you keep the calling thread in another class still it will be weird. Since that class only bound to SurfaceView class. I have done development with LunaLander type implementation and it has given me good results.
I THINK the way you do it doesn't matter in the compile and run level, it's only matters at the level where other people understanding your code.
精彩评论