mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 11:18:54 +01:00
loop: Bug fix: the clock needs to be stopped when the window is unfocused
This commit is contained in:
parent
f591ca3d2b
commit
717efd097d
@ -142,9 +142,15 @@ func (c *runContext) updateCount(now int64) int {
|
|||||||
count = int(f - c.frames)
|
count = int(f - c.frames)
|
||||||
}
|
}
|
||||||
c.lastClockFrame = f
|
c.lastClockFrame = f
|
||||||
|
} else {
|
||||||
|
if t > 5*int64(time.Second)/int64(clock.FPS) {
|
||||||
|
// The previous time is too old. Let's assume that the window was unfocused.
|
||||||
|
count = 0
|
||||||
|
c.lastUpdated = now
|
||||||
} else {
|
} else {
|
||||||
count = int(t * int64(clock.FPS) / int64(time.Second))
|
count = int(t * int64(clock.FPS) / int64(time.Second))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Stabilize FPS.
|
// Stabilize FPS.
|
||||||
if count == 0 && (int64(time.Second)/int64(clock.FPS)/2) < t {
|
if count == 0 && (int64(time.Second)/int64(clock.FPS)/2) < t {
|
||||||
|
Loading…
Reference in New Issue
Block a user