Repos / shark / e9665ef363
commit e9665ef36308aaa8a00378f39282f89608018db4
Author: Bùi Thành Nhân <hi@imnhan.com>
Date: Wed Jun 29 20:17:01 2022 +0700
fix go:embed asset paths
Turns out in an embeded FS, the path separator is always "/", even on
Windows.
diff --git a/main.go b/main.go
index ceca17c..a2f10bb 100644
--- a/main.go
+++ b/main.go
@@ -5,7 +5,6 @@
"embed"
_ "image/png"
"log"
- "path/filepath"
"github.com/hajimehoshi/ebiten/v2"
"github.com/hajimehoshi/ebiten/v2/ebitenutil"
@@ -138,12 +137,12 @@ func (g *Game) Layout(outsideWidth, outsideHeight int) (w, h int) {
}
func NewAnim(sprites embed.FS, subdir string) *Anim {
- files, err := sprites.ReadDir(filepath.Join("sprites", subdir))
+ files, err := sprites.ReadDir("sprites/" + subdir)
PanicIfErr(err)
var frames []*ebiten.Image
for _, direntry := range files {
fname := direntry.Name()
- frame, err := sprites.ReadFile(filepath.Join("sprites", subdir, fname))
+ frame, err := sprites.ReadFile("sprites/" + subdir + "/" + fname)
PanicIfErr(err)
img, _, err := ebitenutil.NewImageFromReader(bytes.NewReader(frame))
PanicIfErr(err)