import pygame
import os
+from eventutils import EventHandlerMixin, event_handler
+from itertools import cycle
+from pygame.locals import USEREVENT
+TIMEOUT = USEREVENT + 1
-
-class WarpingCursor(pygame.sprite.Sprite):
+class WarpingCursor(pygame.sprite.Sprite, EventHandlerMixin):
'''
The class for animating the warping cursor
surface = pygame.display.get_surface()
surface.blit(self.image, self.rect)
+ self._startBlink()
#self.flashImagePath = flashImage
#self.durations = durations
#self._imagePointer = 0
#self._animationOffset = 0
#self._flashTimer = 0
+
+ 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) :
+ self.image = self.iterator.next()
+ surface = pygame.display.get_surface()
+ surface.blit(self.image, self.rect)
def update(self) :
print 'cursor update'