Example #1
0
    def __init__(self, image, position=(0, 0), rotation=0, 
                                               scale=1, 
                                               opacity=255, 
                                               color=(255, 255, 255), 
                                               anchor=None,
                                               batch=None,
                                               group=None):
        '''
        Create a sprite.

        :Parameters:
            image : string or image
                Name of the image resource or a pyglet image.
            position : tuple
                Position of the anchor. Defaults to (0,0).
            rotation : float
                The rotation (degrees). Defaults to 0.
            scale : float
                The zoom factor. Defaults to 1.
            opacity : int
                The opacity (0=transparent, 255=opaque). Defaults to 255.
            color : tuple
                The color to colorize the child (RGB 3-tuple). Defaults to 
                (255,255,255).
            anchor : (float, float)
                (x,y)-point from where the image will be positions, rotated and 
                scaled in pixels. For example (image.width/2, image.height/2) 
                is the center (default).
        '''
        if isinstance(image, basestring):
            image = load_image(image)

        BatmaNode.__init__(self)
        pyglet.sprite.Sprite.__init__(self, image, batch=batch, group=group)

        anchor = anchor or "center"

        if isinstance(self.image, (pyglet.image.Animation, list, tuple)):
            _anchor_animation(self.image, anchor)
        else:
            _anchor_image(self.image, anchor)

        self.position = position
        self.rotation = rotation
        self.scale = scale
        self.opacity = opacity
        self.color = color

        self.__must_update = True
Example #2
0
 def set_rotation(self, angle):
     BatmaNode.set_rotation(self, angle)
     self.__must_update = True
Example #3
0
 def set_y(self, y):
     BatmaNode.set_y(self, y)
     self.__must_update = True
Example #4
0
 def set_scale(self, factor):
     BatmaNode.set_scale(self, factor)
     self.__must_update = True
Example #5
0
 def set_x(self, x):
     BatmaNode.set_x(self, x)
     self.__must_update = True