mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +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() {
|
func vsync() {
|
||||||
ch := make(chan struct{})
|
ch := make(chan struct{})
|
||||||
// TODO: In iOS8, this is called at every 1/30[sec] frame.
|
// As the performance is generally not good with GopehrJS, consume n 'requestAnimationFrame's
|
||||||
// Can we use DOMHighResTimeStamp?
|
// each time.
|
||||||
js.Global.Get("window").Call("requestAnimationFrame", func() {
|
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)
|
close(ch)
|
||||||
})
|
}
|
||||||
|
l()
|
||||||
<-ch
|
<-ch
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user