mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 10:48:53 +01:00
examples/wav: Play SE immediately
This commit is contained in:
parent
b1c67c7661
commit
10f394f72b
@ -25,6 +25,7 @@ import (
|
|||||||
"github.com/hajimehoshi/ebiten/v2/audio/wav"
|
"github.com/hajimehoshi/ebiten/v2/audio/wav"
|
||||||
"github.com/hajimehoshi/ebiten/v2/ebitenutil"
|
"github.com/hajimehoshi/ebiten/v2/ebitenutil"
|
||||||
raudio "github.com/hajimehoshi/ebiten/v2/examples/resources/audio"
|
raudio "github.com/hajimehoshi/ebiten/v2/examples/resources/audio"
|
||||||
|
"github.com/hajimehoshi/ebiten/v2/inpututil"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -73,7 +74,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *Game) Update() error {
|
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,
|
// As audioPlayer has one stream and remembers the playing position,
|
||||||
// rewinding is needed before playing when reusing audioPlayer.
|
// rewinding is needed before playing when reusing audioPlayer.
|
||||||
g.audioPlayer.Rewind()
|
g.audioPlayer.Rewind()
|
||||||
|
Loading…
Reference in New Issue
Block a user