Skip to content

Commit

Permalink
fix go:embed asset paths
Browse files Browse the repository at this point in the history
Turns out in an embeded FS, the path separator is always "/", even on
Windows.
  • Loading branch information
nhanb committed Jun 29, 2022
1 parent 592dba9 commit e9665ef
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"embed"
_ "image/png"
"log"
"path/filepath"

"github.com/hajimehoshi/ebiten/v2"
"github.com/hajimehoshi/ebiten/v2/ebitenutil"
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit e9665ef

Please sign in to comment.