开发者

Java game: Keeping framerate the same on all computers

开发者 https://www.devze.com 2023-04-05 12:29 出处:网络
COMPLETE EDIT: After reading comments, I changed to a Timer with Timer(33,this);, however on my laptop it\'s repeating at 47 (and constantly bouncing around to other numbers) whe开发者_Go百科reas my

COMPLETE EDIT:

After reading comments, I changed to a Timer with Timer(33,this);, however on my laptop it's repeating at 47 (and constantly bouncing around to other numbers) whe开发者_Go百科reas my computer stays at the perfect 33.

Is there a common problem with timers I'm missing here? Thanks.


I dont think you are taking the right approach, you shouldn't try to keep all the computers running at the same FPS, in fact no game that I know does that. Instead you should make sure that every x fraction of time the same movements happen regardless of the fps for that particular computer.


Time Based Animation is what you want to be looking at.


Use javax.swing.Timer, as shown in this AnimationTest.

0

精彩评论

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

关注公众号