Mercurial > pyntnclick
changeset 172:3b5cfb3f794e
Ensure cursor loaded when calling set_highlight
author | Stefano Rivera <stefano@rivera.za.net> |
---|---|
date | Wed, 25 Aug 2010 13:12:14 +0200 |
parents | a1162ea4ad67 |
children | e77e331c874b |
files | gamelib/cursor.py |
diffstat | 1 files changed, 2 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/gamelib/cursor.py Wed Aug 25 12:41:08 2010 +0200 +++ b/gamelib/cursor.py Wed Aug 25 13:12:14 2010 +0200 @@ -18,6 +18,7 @@ self.filename = filename self.pointer_x = x self.pointer_y = y + self.highlighted = False def load(self): if not hasattr(self, 'plain_image'): @@ -27,7 +28,6 @@ self.highlight = pygame.Surface(self.rect.size) color = pygame.color.Color(255, 100, 100, 0) self.highlight.fill(color) - self.highlighted = False def update(self): pos = pygame.mouse.get_pos() @@ -35,10 +35,8 @@ self.rect.top = pos[1] - self.pointer_y def set_highlight(self, enable): - if not hasattr(self, 'plain_image'): - # do nothing if we're not loaded yet - return if enable != self.highlighted: + self.load() self.highlighted = enable self.image = self.plain_image.copy() if enable: