From 10f394f72bffd4b8e015c3548cf7d6a51797e782 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 10 Oct 2020 05:03:51 +0900 Subject: [PATCH] examples/wav: Play SE immediately --- examples/wav/main.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/wav/main.go b/examples/wav/main.go index dd2d2fbc7..6e254c2ab 100644 --- a/examples/wav/main.go +++ b/examples/wav/main.go @@ -25,6 +25,7 @@ import ( "github.com/hajimehoshi/ebiten/v2/audio/wav" "github.com/hajimehoshi/ebiten/v2/ebitenutil" raudio "github.com/hajimehoshi/ebiten/v2/examples/resources/audio" + "github.com/hajimehoshi/ebiten/v2/inpututil" ) const ( @@ -73,7 +74,7 @@ func init() { } func (g *Game) Update() error { - if ebiten.IsKeyPressed(ebiten.KeyP) && !g.audioPlayer.IsPlaying() { + if inpututil.IsKeyJustPressed(ebiten.KeyP) { // As audioPlayer has one stream and remembers the playing position, // rewinding is needed before playing when reusing audioPlayer. g.audioPlayer.Rewind()