examples: audioContext.Update should be called at last

This commit is contained in:
Hajime Hoshi 2016-04-22 01:11:28 +09:00
parent 3c3d275e5e
commit 62243f97b5
4 changed files with 13 additions and 12 deletions

View File

@ -181,9 +181,6 @@ func (p *Player) close() error {
}
func update(screen *ebiten.Image) error {
if err := audioContext.Update(); err != nil {
return err
}
if musicPlayer == nil {
select {
case musicPlayer = <-musicCh:
@ -242,6 +239,9 @@ Press Z or X to change volume of the music
msg += "\nNow Loading..."
}
ebitenutil.DebugPrint(screen, msg)
if err := audioContext.Update(); err != nil {
return err
}
return nil
}

View File

@ -145,9 +145,6 @@ func addNote() error {
}
func update(screen *ebiten.Image) error {
if err := audioContext.Update(); err != nil {
return err
}
defer func() {
frames++
}()
@ -157,6 +154,9 @@ func update(screen *ebiten.Image) error {
}
}
ebitenutil.DebugPrint(screen, fmt.Sprintf("FPS: %0.2f", ebiten.CurrentFPS()))
if err := audioContext.Update(); err != nil {
return err
}
return nil
}

View File

@ -206,9 +206,6 @@ func init() {
}
func update(screen *ebiten.Image) error {
if err := audioContext.Update(); err != nil {
return err
}
updateInput()
for i, key := range keys {
if keyStates[key] != 1 {
@ -223,6 +220,10 @@ 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

@ -87,9 +87,6 @@ func (s *stream) Close() error {
var player *audio.Player
func update(screen *ebiten.Image) error {
if err := audioContext.Update(); err != nil {
return err
}
if player == nil {
var err error
player, err = audio.NewPlayer(audioContext, &stream{})
@ -101,6 +98,9 @@ func update(screen *ebiten.Image) error {
}
}
ebitenutil.DebugPrint(screen, fmt.Sprintf("FPS: %0.2f", ebiten.CurrentFPS()))
if err := audioContext.Update(); err != nil {
return err
}
return nil
}