mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
ui: Frame skip on JS
This commit is contained in:
parent
5e5eea59ce
commit
246ac055bf
@ -78,11 +78,21 @@ func shown() bool {
|
||||
|
||||
func vsync() {
|
||||
ch := make(chan struct{})
|
||||
// TODO: In iOS8, this is called at every 1/30[sec] frame.
|
||||
// Can we use DOMHighResTimeStamp?
|
||||
js.Global.Get("window").Call("requestAnimationFrame", func() {
|
||||
// As the performance is generally not good with GopehrJS, consume n 'requestAnimationFrame's
|
||||
// each time.
|
||||
n := 2
|
||||
var l func()
|
||||
l = func() {
|
||||
if 0 < n {
|
||||
n--
|
||||
// TODO: In iOS8, this is called at every 1/30[sec] frame.
|
||||
// Can we use DOMHighResTimeStamp?
|
||||
js.Global.Get("window").Call("requestAnimationFrame", l)
|
||||
return
|
||||
}
|
||||
close(ch)
|
||||
})
|
||||
}
|
||||
l()
|
||||
<-ch
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user