Make the menu buttons work
This commit is contained in:
@@ -2,6 +2,7 @@ package assetstore
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"image"
|
||||
"log"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -23,12 +24,13 @@ type Object struct {
|
||||
type Sprite struct {
|
||||
obj *Object
|
||||
|
||||
ID string
|
||||
XOffset int
|
||||
XOffset int // TODO: replace these everywhere with Rect
|
||||
YOffset int
|
||||
Width int
|
||||
Height int
|
||||
|
||||
ID string
|
||||
Rect image.Rectangle
|
||||
Image *ebiten.Image
|
||||
}
|
||||
|
||||
@@ -106,13 +108,21 @@ func (o *Object) Sprite(idx int) (*Sprite, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rect := image.Rect(
|
||||
int(raw.XOffset),
|
||||
int(raw.YOffset),
|
||||
int(raw.XOffset+raw.Width),
|
||||
int(raw.YOffset+raw.Height),
|
||||
)
|
||||
|
||||
sprite := &Sprite{
|
||||
ID: fmt.Sprintf("%v:%v", o.raw.Name, idx),
|
||||
obj: o,
|
||||
Width: int(raw.Width),
|
||||
Height: int(raw.Width),
|
||||
XOffset: int(raw.XOffset),
|
||||
YOffset: int(raw.YOffset),
|
||||
Width: rect.Dx(),
|
||||
Height: rect.Dy(),
|
||||
XOffset: rect.Min.X,
|
||||
YOffset: rect.Min.Y,
|
||||
Rect: rect,
|
||||
Image: img,
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user