- elapsedTime:
- The time passed since the previous update
- '''
- self._animationOffset += elapsedTime
-
- if self._animationOffset > self.duration :
- #New animation offset is computed first, before updating the pointer
- self._animationOffset -= self.duration
- #point to the next image (restarts from the beginning when it reaches the end)
- self._imagePointer = (self._imagePointer + 1) % len(self.images)
-
- if self.flashing:
- self.image = pygame.image.load(self.flashImagePath).convert_alpha()
+ def iterImages(self) :
+ for img in cycle(self.images) :
+ yield img
+
+ @event_handler(TIMEOUT)
+ def loadNext(self, event) :
+ 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
+ self.loadNext(event)