开发者

Using Threads in android games

开发者 https://www.devze.com 2023-03-06 07:09 出处:网络
I\'ve been reading stuff about android game development and performance optimization. And i have two questions:

I've been reading stuff about android game development and performance optimization. And i have two questions:

Supose i have a game, and in that game i use one thread for drawing stuff on a canvas. when I fire a bullet i want an explosion to happen at contact with another surface. will the game wait for the explosion to render and then continue to render the rest of the animations etc? or will it all happen at the same 开发者_StackOverflow中文版time?

The second question is about the garbage collector, and if anyone could give me some hints or post a link to something about it regardin games performance.

Thank you very much.


will the game wait for the explosion to render and then continue to render the rest of the animations etc?

Not unless you do something to specifically make the game wait for the events to execute in a certain order. If you have synchronized access to the canvas, then all that will be guaranteed is that the two threads will not draw on the canvas at the same time, but the order in which they draw, and when they draw, is not guaranteed.

or will it all happen at the same time?

The order in which the drawing will occur may be concurrent, so you could say it's happening in the same time. However, it's recommended that only one thread draws on the canvas.

If I were you I would try to get a decent 2D/3D game engine for android and worry about your game more than the multithreading and garbage collection behind it.

0

精彩评论

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