- def update(self, elapsedTime, centerPosition):
- '''
- Update the cursor's look and position
-
- elapsedTime:
- The time passed since the previous update
- centerPosition:
- the new position of the creep
- '''
- self._updateImage(elapsedTime)
- self.centerPosition = centerPosition
- if self.flashing :
- self._flashTimer += elapsedTime
- if self._flashTimer > self.flashLength:
- self.flashing = False
+ def _startBlink(self) :
+ pygame.time.set_timer(TIMEOUT, self.duration)
+ self.iterator = self.iterImages()
+
+ def iterImages(self) :
+ for img in cycle(self.images) :
+ yield img
+
+ @event_handler(TIMEOUT)
+ def loadNext(self, event) :
+ if self.blink :
+ self.image = self.iterator.next()
+ surface = pygame.display.get_surface()
+ surface.blit(self.image, self.rect)
+
+ @event_handler(MOUSEBUTTONDOWN)
+ def flashOn(self, event) :
+ self.blink=False
+ self.image = self.flashImage
+ surface = pygame.display.get_surface()
+ surface.blit(self.image, self.rect)
+
+ @event_handler(MOUSEBUTTONUP)
+ def flashOff(self, event) :
+ self.blink = True
+ self.loadNext(event)
+
+ def update(self) :
+ print 'cursor update'
+
+# def update(self, elapsedTime, centerPosition):
+# '''
+# Update the cursor's look and position
+#
+# elapsedTime:
+# The time passed since the previous update
+# centerPosition:
+# the new position of the creep
+# '''
+# self._updateImage(elapsedTime)
+# self.centerPosition = centerPosition
+# if self.flashing :
+# self._flashTimer += elapsedTime
+# if self._flashTimer > self.flashLength:
+# self.flashing = False