comparison gamelib/widgets.py @ 450:ece69836f00a

Image buttons for game over screen
author Neil Muller <neil@dip.sun.ac.za>
date Sun, 29 Aug 2010 00:50:25 +0200
parents 05d15be39377
children 03dcb25d8370
comparison
equal deleted inserted replaced
449:a30f91ee5b33 450:ece69836f00a
174 item = self.present(self.shell, (0, menu_top)) 174 item = self.present(self.shell, (0, menu_top))
175 if item > -1: 175 if item > -1:
176 # A menu item needs to be invoked 176 # A menu item needs to be invoked
177 self.invoke_item(item) 177 self.invoke_item(item)
178 178
179 class BoomImageButton(albow.controls.Image):
180 """The fancy image button for the screens"""
181
182 FOLDER = None
183
184 def __init__(self, filename, x, y, action, enable=None):
185 this_image = get_image(self.FOLDER, filename)
186 albow.controls.Image.__init__(self, image=this_image)
187 self.action = action
188 self.set_rect(Rect((x, y), this_image.get_size()))
189 self.enable = enable
190
191 def draw(self, surface):
192 if self.is_enabled():
193 surface.blit(self.get_image(), self.get_rect())
194
195 def mouse_down(self, event):
196 if self.is_enabled():
197 self.action()
198
199 def is_enabled(self):
200 if self.enable:
201 return self.enable()
202 return True
203