def __init__(self, image, position=(0, 0), rotation=0, scale=1, opacity=255, color=(255, 255, 255), anchor=None, **kwargs): if isinstance(image, string_types): image = pyglet.resource.image(image) self.transform_anchor_x = 0 self.transform_anchor_y = 0 self._image_anchor_x = 0 self._image_anchor_y = 0 # These need to be forward-defined here because pyglet<1.3 sprites don't have them. self._scale_x = 1 self._scale_y = 1 pyglet.sprite.Sprite.__init__(self, image, **kwargs) BatchableNode.__init__(self) if anchor is None: if isinstance(self.image, pyglet.image.Animation): anchor = (image.frames[0].image.width // 2, image.frames[0].image.height // 2) else: anchor = image.width // 2, image.height // 2 self.image_anchor = anchor # group. # This is for batching self.group = None # children group. # This is for batching self.children_group = None #: position of the sprite in (x, y) coordinates self.position = position #: rotation in degrees of the sprite. Default: 0 degrees self.rotation = rotation #: scale of the sprite where 1.0 is the default value self.scale = scale #: additional horizontal-only scale of the sprite where 1.0 is the default value self.scale_x = 1 #: additional vertical-only scale of the sprite where 1.0 is the default value self.scale_y = 1 #: opacity of the sprite where 0 is transparent and 255 is solid self.opacity = opacity #: color of the sprite in R, G, B format where 0, 0, 0 is black and #: 255, 255, 255 is white self.color = color
def __init__(self, image, position=(0, 0), rotation=0, scale=1, opacity=255, color=(255, 255, 255), anchor=None, **kwargs): if isinstance(image, string_types): image = pyglet.resource.image(image) self.transform_anchor_x = 0 self.transform_anchor_y = 0 self._image_anchor_x = 0 self._image_anchor_y = 0 # These need to be forward-defined here because pyglet sprites don't have them. self._scale_x = 1 self._scale_y = 1 pyglet.sprite.Sprite.__init__(self, image, **kwargs) BatchableNode.__init__(self) if anchor is None: if isinstance(self.image, pyglet.image.Animation): anchor = (image.frames[0].image.width // 2, image.frames[0].image.height // 2) else: anchor = image.width // 2, image.height // 2 self.image_anchor = anchor # group. # This is for batching self.group = None # children group. # This is for batching self.children_group = None #: position of the sprite in (x, y) coordinates self.position = position #: rotation in degrees of the sprite. Default: 0 degrees self.rotation = rotation #: scale of the sprite where 1.0 is the default value self.scale = scale #: additional horizontal-only scale of the sprite where 1.0 is the default value self.scale_x = 1 #: additional vertical-only scale of the sprite where 1.0 is the default value self.scale_y = 1 #: opacity of the sprite where 0 is transparent and 255 is solid self.opacity = opacity #: color of the sprite in R, G, B format where 0, 0, 0 is black and #: 255, 255, 255 is white self.color = color
def __init__(self, top_left, pokemon, height=15): """ :param top_left: :type top_left: tuple[int, int] :param pokemon: :type pokemon: pokemon.Pokemon :param height: :type height: int """ BatchableNode.__init__(self) self.x, self.y = top_left self.pokemon = pokemon self.max_width = 150 self.height = height self.pokemon.push_handlers(self)
def __init__(self, image, position=(0, 0), rotation=0, scale=1, opacity = 255, color=(255, 255, 255), anchor = None): """Initialize the 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. `scale_x` : float additional horizontal-only zoom factor. Defaults to 1. `scale_y` : float additional vertical-only 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, string_types): image = pyglet.resource.image(image) self.transform_anchor_x = 0 self.transform_anchor_y = 0 self._image_anchor_x = 0 self._image_anchor_y = 0 # These need to be forward-defined here because pyglet sprites don't have them. self._scale_x = 1 self._scale_y = 1 pyglet.sprite.Sprite.__init__(self, image) BatchableNode.__init__(self) if anchor is None: if isinstance(self.image, pyglet.image.Animation): anchor = (image.frames[0].image.width // 2, image.frames[0].image.height // 2) else: anchor = image.width // 2, image.height // 2 self.image_anchor = anchor # group. # This is for batching self.group = None # children group. # This is for batching self.children_group = None #: position of the sprite in (x,y) coordinates self.position = position #: rotation degrees of the sprite. Default: 0 degrees self.rotation = rotation #: scale of the sprite where 1.0 the default value self.scale = scale #: additional horizontal-only scale of the sprite where 1.0 the default value self.scale_x = 1 #: additional vertical-only scale of the sprite where 1.0 the default value self.scale_y = 1 #: opacity of the sprite where 0 is transparent and 255 is solid self.opacity = opacity #: color of the sprite in R,G,B format where 0,0,0 is black and 255,255,255 is white self.color = color
def __init__(self, image, position=(0, 0), rotation=0, scale=1, opacity=255, color=(255, 255, 255), anchor=None): '''Initialize the 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. `scale_x` : float additional horizontal-only zoom factor. Defaults to 1. `scale_y` : float additional vertical-only 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, string_types): image = pyglet.resource.image(image) self.transform_anchor_x = 0 self.transform_anchor_y = 0 self._image_anchor_x = 0 self._image_anchor_y = 0 # These need to be forward-defined here because pyglet sprites don't have them. self._scale_x = 1 self._scale_y = 1 pyglet.sprite.Sprite.__init__(self, image) BatchableNode.__init__(self) if anchor is None: if isinstance(self.image, pyglet.image.Animation): anchor = (image.frames[0].image.width // 2, image.frames[0].image.height // 2) else: anchor = image.width // 2, image.height // 2 self.image_anchor = anchor # group. # This is for batching self.group = None # children group. # This is for batching self.children_group = None #: position of the sprite in (x,y) coordinates self.position = position #: rotation degrees of the sprite. Default: 0 degrees self.rotation = rotation #: scale of the sprite where 1.0 the default value self.scale = scale #: additional horizontal-only scale of the sprite where 1.0 the default value self.scale_x = 1 #: additional vertical-only scale of the sprite where 1.0 the default value self.scale_y = 1 #: opacity of the sprite where 0 is transparent and 255 is solid self.opacity = opacity #: color of the sprite in R,G,B format where 0,0,0 is black and 255,255,255 is white self.color = color