开发者

Android render and logic threads

开发者 https://www.devze.com 2023-01-30 11:27 出处:网络
On the Android platform, how would I separate the rendering from the logic? I can get a basic custom thread class doing the drawing but what I don\'t get is where to put the logic update.开发者_如何学

On the Android platform, how would I separate the rendering from the logic? I can get a basic custom thread class doing the drawing but what I don't get is where to put the logic update.开发者_如何学Go Doing some research, I think it would be best to use two different threads one for each, rendering and logic updating. All I can think of atm is to updatelogic with the onDraw in the same thread. Any pointers to tutorials or some insight on the matter would be much appreciated, thanks.


I developed one of the most downloaded games on the android marketplace, but it's been 2 years since then so this solution may be obsolete. What I did was: - use a View object as the content view - override the draw() method of that View object's class - at the end of the draw() method, call doLogic()

Notice that both the rendering and the doLogic() call happen in the main thread. This sounds like a no-no, but it works for most games (and gives you automatic synchronization without having to get complicated).

0

精彩评论

暂无评论...
验证码 换一张
取 消