mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
examples/audio: Add the player bar
This commit is contained in:
parent
eb0d650612
commit
0fb5dffbf5
@ -75,8 +75,16 @@ func update(screen *ebiten.Image) error {
|
|||||||
y := float64(screenHeight - h - 16)
|
y := float64(screenHeight - h - 16)
|
||||||
op.GeoM.Translate(x, y)
|
op.GeoM.Translate(x, y)
|
||||||
screen.DrawImage(playerBarImage, op)
|
screen.DrawImage(playerBarImage, op)
|
||||||
|
currentTimeStr := ""
|
||||||
if audioLoaded && audioPlayer.IsPlaying() {
|
if audioLoaded && audioPlayer.IsPlaying() {
|
||||||
c := audioPlayer.Current()
|
c := audioPlayer.Current()
|
||||||
|
|
||||||
|
// Current Time
|
||||||
|
m := (c / time.Minute) % 100
|
||||||
|
s := (c / time.Second) % 60
|
||||||
|
currentTimeStr = fmt.Sprintf("%02d:%02d", m, s)
|
||||||
|
|
||||||
|
// Bar
|
||||||
w, _ := playerBarImage.Size()
|
w, _ := playerBarImage.Size()
|
||||||
cw, ch := playerCurrentImage.Size()
|
cw, ch := playerCurrentImage.Size()
|
||||||
cx := float64(w)*float64(c)/float64(total) + x - float64(cw)/2
|
cx := float64(w)*float64(c)/float64(total) + x - float64(cw)/2
|
||||||
@ -86,7 +94,8 @@ func update(screen *ebiten.Image) error {
|
|||||||
screen.DrawImage(playerCurrentImage, op)
|
screen.DrawImage(playerCurrentImage, op)
|
||||||
}
|
}
|
||||||
|
|
||||||
msg := fmt.Sprintf("FPS: %0.2f", ebiten.CurrentFPS())
|
msg := fmt.Sprintf(`FPS: %0.2f
|
||||||
|
%s`, ebiten.CurrentFPS(), currentTimeStr)
|
||||||
if !audioLoaded {
|
if !audioLoaded {
|
||||||
msg += "\nNow Loading..."
|
msg += "\nNow Loading..."
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user