sprite is now Transformer
This commit is contained in:
parent
7d45922c04
commit
400552e742
2 changed files with 7 additions and 8 deletions
BIN
cpuprofile.pprof
BIN
cpuprofile.pprof
Binary file not shown.
|
@ -11,6 +11,7 @@ import (
|
||||||
var _ interface {
|
var _ interface {
|
||||||
Drawer
|
Drawer
|
||||||
Scanner
|
Scanner
|
||||||
|
Transformer
|
||||||
Updater
|
Updater
|
||||||
} = &Sprite{}
|
} = &Sprite{}
|
||||||
|
|
||||||
|
@ -30,14 +31,7 @@ type Sprite struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Sprite) Draw(screen *ebiten.Image, opts ebiten.DrawImageOptions) {
|
func (s *Sprite) Draw(screen *ebiten.Image, opts ebiten.DrawImageOptions) {
|
||||||
dp := s.Actor.Pos.Add(s.FrameOffset)
|
screen.DrawImage(s.Sheet.SubImage(s.anim.CurrentFrame()), &opts)
|
||||||
var geom ebiten.GeoM
|
|
||||||
geom.Translate(float64(dp.X), float64(dp.Y))
|
|
||||||
geom.Concat(opts.GeoM)
|
|
||||||
opts.GeoM = geom
|
|
||||||
|
|
||||||
src := s.Sheet.SubImage(s.anim.CurrentFrame())
|
|
||||||
screen.DrawImage(src, &opts)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Sprite) Scan() []interface{} {
|
func (s *Sprite) Scan() []interface{} {
|
||||||
|
@ -54,5 +48,10 @@ func (s *Sprite) SetAnim(a *Anim) {
|
||||||
s.anim = a
|
s.anim = a
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Sprite) Transform() (opts ebiten.DrawImageOptions) {
|
||||||
|
opts.GeoM.Translate(float2(s.Actor.Pos.Add(s.FrameOffset)))
|
||||||
|
return opts
|
||||||
|
}
|
||||||
|
|
||||||
// anim isn't returned from Scan so we must update it ourselves
|
// anim isn't returned from Scan so we must update it ourselves
|
||||||
func (s *Sprite) Update() error { return s.anim.Update() }
|
func (s *Sprite) Update() error { return s.anim.Update() }
|
||||||
|
|
Loading…
Reference in a new issue