example/sprites: Speed up by caching the image size

This commit is contained in:
Hajime Hoshi 2015-01-17 01:48:28 +09:00
parent edce4027bd
commit f186d1b286

View File

@ -64,11 +64,6 @@ func (s *Sprite) Update() {
}
}
func (s *Sprite) Dst() (x0, y0, x1, y1 int) {
w, h := s.image.Size()
return s.x, s.y, s.x + w, s.y + h
}
type Sprites []*Sprite
func (s Sprites) Update() {
@ -82,7 +77,8 @@ func (s Sprites) Len() int {
}
func (s Sprites) Dst(i int) (x0, y0, x1, y1 int) {
return s[i].Dst()
ss := s[i]
return ss.x, ss.y, ss.x + ebitenImageWidth, ss.y + ebitenImageHeight
}
func (s Sprites) Src(i int) (x0, y0, x1, y1 int) {