Ejemplo n.º 1
0
 def getSpriteListFromAtlas(source,sqs):
     #sqs = 'square size'
     atlas = Image(source=source).texture
     atlas.mag_filter = 'nearest'
     regions_x = atlas.width/sqs
     regions_y = atlas.height/sqs
     spriteList = []
     for i in range(0,regions_y):
         for b in range(0,regions_x):
             coords = b*sqs,i*sqs,sqs,sqs
             region = atlas.get_region(coords[0],coords[1],coords[2],coords[3])
             spriteList.append(Sprite(region))       
     return spriteList
Ejemplo n.º 2
0
    def add_image(self, base_path, file):
        if not os.path.exists(file):
            file = os.path.join(base_path, file)
        texture = Image(source=file).texture
        texture.mag_filter = 'nearest'
        if texture is None:
            sys.exit('failed to locate image file %r' % file)

        id = self.firstgid
        th = self.tile_height + self.spacing
        tw = self.tile_width + self.spacing
        for j in xrange(texture.height / th):
            for i in xrange(texture.width / tw):
                x = (i * tw) + self.margin
                # convert the y coordinate to OpenGL (0 at bottom of texture)
                y = texture.height - ((j + 1) * th)
                tile = texture.get_region(x, y, self.tile_width, self.tile_height)
                self.tiles.append(Tile(id, tile, self))
                id += 1
Ejemplo n.º 3
0
    def add_image(self, base_path, file):
        if not os.path.exists(file):
            file = os.path.join(base_path, file)
        texture = Image(source=file).texture
        texture.mag_filter = 'nearest'
        if texture is None:
            sys.exit('failed to locate image file %r' % file)

        id = self.firstgid
        th = self.tile_height + self.spacing
        tw = self.tile_width + self.spacing
        for j in xrange(texture.height / th):
            for i in xrange(texture.width / tw):
                x = (i * tw) + self.margin
                # convert the y coordinate to OpenGL (0 at bottom of texture)
                y = texture.height - ((j + 1) * th)
                tile = texture.get_region(x, y, self.tile_width,
                                          self.tile_height)
                self.tiles.append(Tile(id, tile, self))
                id += 1