Documentation
¶
Overview ¶
Package loader provides an asset loading and caching implementation.
Index ¶
- type AssetLoader
- func (al *AssetLoader) GetReader(path string) (io.ReadCloser, error)
- func (al *AssetLoader) LoadConcurrentDirectory(path, extension string, total int) []*ebiten.Image
- func (al *AssetLoader) LoadContiguousSubImages(width, height, cols int, rootPath string) ([]*ebiten.Image, error)
- func (al *AssetLoader) LoadImage(path string) (*ebiten.Image, error)
- func (al *AssetLoader) LoadSubImage(rootPath string, rect image.Rectangle) (*ebiten.Image, error)
- func (al *AssetLoader) MustGetReader(path string) io.ReadCloser
- func (al *AssetLoader) MustLoadImage(path string) *ebiten.Image
- func (al *AssetLoader) MustLoadSubImage(rootPath string, rect image.Rectangle) *ebiten.Image
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AssetLoader ¶
type AssetLoader struct {
// contains filtered or unexported fields
}
AssetLoader is the struct that uses a fs.FS file system and a map for caching game assets.
func NewAssetLoader ¶
func NewAssetLoader(dir fs.FS) *AssetLoader
NewAssetLoader takes the directory (dir fs.FS) and creates a new AssetLoader
func (*AssetLoader) GetReader ¶
func (al *AssetLoader) GetReader(path string) (io.ReadCloser, error)
GetReader takes a path (with relation to the root directory of the asset file), returns a io.ReadCloser to interact with
path -> complete path of the asset rooted at the fs.FS
io.ReadCloser, error
func (*AssetLoader) LoadConcurrentDirectory ¶
func (al *AssetLoader) LoadConcurrentDirectory(path, extension string, total int) []*ebiten.Image
LoadConcurrentDirectory takes a path (with relation to the root directory of the fs.FS), an asset file extension, and how many items exist in the directory
path -> goes to a directory of index named files 0.png, 1.png, 2.png extension -> the extension of the files total -> how many files exist in the directory
[]*ebiten.Image
func (*AssetLoader) LoadContiguousSubImages ¶ added in v0.1.6
func (al *AssetLoader) LoadContiguousSubImages(width, height, cols int, rootPath string) ([]*ebiten.Image, error)
LoadContiguousSubImages will extract individual frames from a parent image and return them as an array of *ebiten.Image
func (*AssetLoader) LoadImage ¶
func (al *AssetLoader) LoadImage(path string) (*ebiten.Image, error)
LoadImage takes the path, with relation to the root directory of the embeded fs.FS, and returns an *ebiten.Image, error
path -> complete path of the asset rooted at the fs.FS
*ebiten.Image, error
func (*AssetLoader) LoadSubImage ¶ added in v0.1.6
func (al *AssetLoader) LoadSubImage(rootPath string, rect image.Rectangle) (*ebiten.Image, error)
LoadSubImage takes a root image and a rectangle for that image and returns an image for that rectangle
func (*AssetLoader) MustGetReader ¶
func (al *AssetLoader) MustGetReader(path string) io.ReadCloser
MustGetReader takes a path (with relation to the root directory of the asset file), returns a io.ReadCloser to interact with, will panic if the file doesn't exist
path -> complete path of the asset rooted at the fs.FS
io.ReadCloser, error
func (*AssetLoader) MustLoadImage ¶
func (al *AssetLoader) MustLoadImage(path string) *ebiten.Image
MustLoadImage takes a path (with relation to the root directory of the asset file), will panic if the file doesn't exist
path -> complete path of the asset rooted at the fs.FS
*ebiten.Image
func (*AssetLoader) MustLoadSubImage ¶ added in v0.1.6
func (al *AssetLoader) MustLoadSubImage(rootPath string, rect image.Rectangle) *ebiten.Image
MustLoadSubImage just like LoadSubImage but panics if there is an error