- def blit(self,surface):
- '''
- Draw the circle on surface
- '''
-
- newPos = (self.centerPosition[0] - self.image.get_width() / 2, self.centerPosition[1] - self.image.get_height() / 2)
- surface.blit(self.image, newPos)
+ def loadNext(self) :
+ if self._blinking :
+ self.dirty = 1
+ self.image = self.iterator.next()
+
+ @event_handler(pygame.MOUSEBUTTONDOWN)
+ def flashOn(self, event) :
+ self.dirty = 1
+ self._blinking = False
+ self.image = self.flashImage
+
+ @event_handler(pygame.MOUSEBUTTONUP)
+ def flashOff(self, event) :
+ self.dirty = 1
+ if self.blinkMode :
+ self._blinking = True
+ else :
+ self.image = self.images[0]
+
+ @event_handler(pygame.MOUSEMOTION)
+ def move(self, event) :
+ self.dirty = 1
+ self.rect.move_ip(event.rel)
+
+ def setPosition(self, pos) :
+ self.dirty = 1
+ x, y = pos
+ rx, ry = self.rect.centerx, self.rect.centery
+ self.rect.move_ip(x-rx, y-ry)
+
+
+class ForeverTimer(Thread) :
+ def __init__(self, duration, func, *args, **kw) :
+ Thread.__init__(self)
+ self.duration = duration / 1000.
+ self.func = func
+ self.args = args
+ self.kw = kw
+ self.running = True
+
+ def run(self) :
+ while self.running :
+ self.func(*self.args, **self.kw)
+ time.sleep(self.duration)
+
+ def stop(self) :
+ self.running = False
\ No newline at end of file