fix Sprite.SetPicture
This commit is contained in:
parent
7f5a21cd3c
commit
cf4ab7e36a
|
@ -185,6 +185,11 @@ func NewSprite(pic *Picture) *Sprite {
|
||||||
|
|
||||||
// SetPicture changes the Picture of the Sprite and resizes it accordingly.
|
// SetPicture changes the Picture of the Sprite and resizes it accordingly.
|
||||||
func (s *Sprite) SetPicture(pic *Picture) {
|
func (s *Sprite) SetPicture(pic *Picture) {
|
||||||
|
oldPic := s.pic
|
||||||
|
s.pic = pic
|
||||||
|
if oldPic.Bounds().Size == pic.Bounds().Size {
|
||||||
|
return
|
||||||
|
}
|
||||||
w, h := pic.Bounds().Size.XY()
|
w, h := pic.Bounds().Size.XY()
|
||||||
(*s.data)[0].Position = V(0, 0)
|
(*s.data)[0].Position = V(0, 0)
|
||||||
(*s.data)[2].Position = V(w, h)
|
(*s.data)[2].Position = V(w, h)
|
||||||
|
@ -192,7 +197,7 @@ func (s *Sprite) SetPicture(pic *Picture) {
|
||||||
(*s.data)[3].Position = V(0, 0)
|
(*s.data)[3].Position = V(0, 0)
|
||||||
(*s.data)[4].Position = V(w, h)
|
(*s.data)[4].Position = V(w, h)
|
||||||
(*s.data)[5].Position = V(0, h)
|
(*s.data)[5].Position = V(0, h)
|
||||||
s.pic = pic
|
s.td.dirty = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Picture returns the current Picture of the Sprite.
|
// Picture returns the current Picture of the Sprite.
|
||||||
|
|
Loading…
Reference in New Issue