examples/flappy: Bug fix: an audio context was created multiple times

Closes #1739
This commit is contained in:
Hajime Hoshi 2021-08-04 14:54:04 +09:00
parent ddf2310285
commit 852c787743

View File

@ -175,7 +175,9 @@ func (g *Game) init() {
g.pipeTileYs[i] = rand.Intn(6) + 2 g.pipeTileYs[i] = rand.Intn(6) + 2
} }
if g.audioContext == nil {
g.audioContext = audio.NewContext(48000) g.audioContext = audio.NewContext(48000)
}
jumpD, err := vorbis.Decode(g.audioContext, bytes.NewReader(raudio.Jump_ogg)) jumpD, err := vorbis.Decode(g.audioContext, bytes.NewReader(raudio.Jump_ogg))
if err != nil { if err != nil {