examples: Bug fix: updating audio context should sync with updating logic

This commit is contained in:
Hajime Hoshi 2017-06-03 01:46:03 +09:00
parent 7bb917d4f6
commit 91b5d985fe
3 changed files with 9 additions and 10 deletions

View File

@ -182,6 +182,9 @@ func update(screen *ebiten.Image) error {
musicPlayer.updateSE()
musicPlayer.updateVolume()
}
if err := audioContext.Update(); err != nil {
return err
}
if ebiten.IsRunningSlowly() {
return nil
}
@ -227,9 +230,6 @@ Press Z or X to change volume of the music
}
}
ebitenutil.DebugPrint(screen, msg)
if err := audioContext.Update(); err != nil {
return err
}
return nil
}

View File

@ -195,6 +195,9 @@ func update(screen *ebiten.Image) error {
}
addNote(220*math.Exp2(float64(i-1)/12.0), 1.0)
}
if err := audioContext.Update(); err != nil {
return err
}
if ebiten.IsRunningSlowly() {
return nil
}
@ -202,10 +205,6 @@ func update(screen *ebiten.Image) error {
screen.DrawImage(imagePiano, nil)
ebitenutil.DebugPrint(screen, fmt.Sprintf("FPS: %0.2f", ebiten.CurrentFPS()))
if err := audioContext.Update(); err != nil {
return err
}
return nil
}

View File

@ -97,14 +97,14 @@ func update(screen *ebiten.Image) error {
}
player.Play()
}
if err := audioContext.Update(); err != nil {
return err
}
if ebiten.IsRunningSlowly() {
return nil
}
msg := fmt.Sprintf("FPS: %0.2f\nThis is an example using infinite audio stream.", ebiten.CurrentFPS())
ebitenutil.DebugPrint(screen, msg)
if err := audioContext.Update(); err != nil {
return err
}
return nil
}