From f186d1b286b9181390478354401459e121e11af6 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 17 Jan 2015 01:48:28 +0900 Subject: [PATCH] example/sprites: Speed up by caching the image size --- example/sprites/main.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/example/sprites/main.go b/example/sprites/main.go index 5291abdea..31c0f88ce 100644 --- a/example/sprites/main.go +++ b/example/sprites/main.go @@ -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) {