简体   繁体   English

Java SE 2d游戏使用哪些类以获得最佳性能

[英]java SE 2d game which classes to use for best performance

i'm porting my J2ME 2D game engine to J2SE and i was wondering which classes should i use to archive the best performance. 我正在将J2ME 2D游戏引擎移植到J2SE,我想知道应该使用哪些类来归档最佳性能。 I'm currently using SingleFameApplication for creating a window, a FrameView for the main game loop and a JPanel for a surface to render on. 我目前正在使用SingleFameApplication创建一个窗口,一个用于主游戏循环的FrameView和一个用于渲染表面的JPanel。 But this probably wont do.. 但这可能不会。

The problem is when i start the engine in opens a window but when i start executing (rendering + physics + collision detection) it hangs. 问题是当我启动引擎时打开一个窗口,但是当我开始执行(渲染+物理+碰撞检测)时,它挂起了。 Can someone explain which classes to use? 有人可以解释要使用哪些类吗? Should i put the game loop in a new thread (or does frameview have its own thread)? 我应该将游戏循环放到新线程中(还是frameview有其自己的线程)? Should i use JFrame instead of SingleFrameApplication? 我应该使用JFrame而不是SingleFrameApplication吗?

I dont think choosing the right Frame has much to do with this. 我不认为选择正确的框架与此无关。

Could you provide more info of the crash / hang? 您能否提供更多有关崩溃/挂起的信息? Until then I guess we would be shooting in the dark. 在那之前,我想我们会在黑暗中射击。

Yes, always a good idea to have the loop in a Thread (with all the critical processing) and only paint when needed. 是的,将循环包含在线程中(具有所有关键处理)并仅在需要时才进行绘制是一个好主意。 (much like the progress bar analogy) (很像进度条的比喻)

regards 问候

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM