From 40c2fac4f85daf8e201d0928536fedb3110aad25 Mon Sep 17 00:00:00 2001 From: "M. Sz" Date: Sun, 20 Dec 2020 13:50:18 +0100 Subject: [PATCH] Revert "fixed onHover bug in d2ui.Sprite" This reverts commit 8b557062fbee330c0806dfa76979d4ad985cc8d5. --- d2core/d2ui/sprite.go | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/d2core/d2ui/sprite.go b/d2core/d2ui/sprite.go index ed382ec8..4a904add 100644 --- a/d2core/d2ui/sprite.go +++ b/d2core/d2ui/sprite.go @@ -37,25 +37,17 @@ func (ui *UIManager) NewSprite(animationPath, palettePath string) (*Sprite, erro base := NewBaseWidget(ui) - sprite := &Sprite{ + return &Sprite{ BaseWidget: base, animation: animation, Logger: ui.Logger, - } - - sprite.SetVisible(false) - - ui.addWidget(sprite) - - return sprite, nil + }, nil } // Render renders the sprite on the given surface func (s *Sprite) Render(target d2interface.Surface) { _, frameHeight := s.animation.GetCurrentFrameSize() - s.width, s.height = s.animation.GetCurrentFrameSize() - target.PushTranslation(s.x, s.y-frameHeight) defer target.Pop() @@ -101,6 +93,11 @@ func (s *Sprite) RenderSegmented(target d2interface.Surface, segmentsX, segments } } +// GetSize returns the size of the current frame +func (s *Sprite) GetSize() (width, height int) { + return s.GetCurrentFrameSize() +} + // GetFrameSize gets the Size(width, height) of a indexed frame. func (s *Sprite) GetFrameSize(frameIndex int) (x, y int, err error) { return s.animation.GetFrameSize(frameIndex)