Android – timing error in our game, currenttimemillis frozen?

When testing our game, which relies heavily on system. Currenttimemillis (), we encountered an annoying error

Our game uses a set of delta timestamps to indicate when something should happen. These timestamps match a piece of music being played

There is no problem with testing at home. It is impossible to reproduce this bug when testing from our home

But testing while driving between cities will bring us synchronization problems between timestamps and music. My best guess is that Android freezes the system, including the system timer, because it switches the network or looks for signals?

I've tried to insert a fake hick up in the game and let the thread sleep for a few seconds when I press a button. This obviously freezes the screen, but when the sleep is over, everything is still normal

The only way to reproduce this mistake is to travel by car or bus or train - of course, this is probably where most people play games

The problem is, of course,

>What should I do? > Does anyone have any ideas?

resolvent:

Read systemclock

I think it's best to use system. Nanotime()

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>