Eager load used sprites
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package assetstore
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
@@ -18,6 +19,7 @@ type Object struct {
|
||||
type Sprite struct {
|
||||
obj *Object
|
||||
|
||||
ID string
|
||||
XOffset int
|
||||
YOffset int
|
||||
Width int
|
||||
@@ -50,8 +52,8 @@ func (a *AssetStore) Object(name string) (*Object, error) {
|
||||
sprites: make([]*Sprite, int(raw.NumSprites)),
|
||||
raw: raw,
|
||||
}
|
||||
a.objs[name] = obj
|
||||
|
||||
a.objs[name] = obj
|
||||
return obj, nil
|
||||
}
|
||||
|
||||
@@ -75,6 +77,7 @@ func (o *Object) Sprite(idx int) (*Sprite, error) {
|
||||
}
|
||||
|
||||
sprite := &Sprite{
|
||||
ID: fmt.Sprintf("%v:%v", o.raw.Name, idx),
|
||||
obj: o,
|
||||
Width: int(raw.Width),
|
||||
Height: int(raw.Width),
|
||||
|
Reference in New Issue
Block a user