Beispiel #1
0
    class TestLayer(layer.Layer):

        is_event_handler = True

        def __init__(self):
            c = Rect(0, 0, 10,10)
            b = Box(c, red)
            super(TestLayer, self).__init__()
            self.a = Atlas('./data/goblins.atlas')
            self.names = sorted(self.a.region_lib.keys())
            self.i = 17
            print self.names[self.i]
            self.sprite = sprite.Sprite(self.a.get_attachment_region(self.names[self.i]))
            #self.sprite.scale_x = 0.5
            #self.sprite.scale_y = 0.25
            self.b = Box(self.sprite.get_rect(), red)
            self.sprite.add(self.b)
            self.sprite.position = (512, 512)
            self.add(self.sprite, z=1)
            self.add(b, z=1)

        def on_key_press(self, symbol, modifers):
            self.i += 1
            self.i %= len(self.names)
            image = self.a.get_attachment_region(self.names[self.i])
            print self.names[self.i]
            self.sprite.image_anchor = (image.width/2, image.height/2)
            self.sprite.image = image
            #self.sprite.position = (512, 512)
            #self.sprite.anchor = (self.sprite.image.width/2, self.sprite.image.height/2)
            self.b.kill()
            #self.sprite.kill()
            #self.sprite = sprite.Sprite(self.a.get_attachment_region(self.names[self.i]))
            #self.add(self.sprite)
            #self.sprite.position = (512, 512)
            self.b = Box(self.sprite.get_rect(), red)
            self.sprite.add(self.b, z=5)
Beispiel #2
0
 def on_key_press(self, symbol, modifers):
     self.i += 1
     self.i %= len(self.names)
     image = self.a.get_attachment_region(self.names[self.i])
     print self.names[self.i]
     self.sprite.image_anchor = (image.width/2, image.height/2)
     self.sprite.image = image
     #self.sprite.position = (512, 512)
     #self.sprite.anchor = (self.sprite.image.width/2, self.sprite.image.height/2)
     self.b.kill()
     #self.sprite.kill()
     #self.sprite = sprite.Sprite(self.a.get_attachment_region(self.names[self.i]))
     #self.add(self.sprite)
     #self.sprite.position = (512, 512)
     self.b = Box(self.sprite.get_rect(), red)
     self.sprite.add(self.b, z=5)
Beispiel #3
0
 def __init__(self):
     c = Rect(0, 0, 10,10)
     b = Box(c, red)
     super(TestLayer, self).__init__()
     self.a = Atlas('./data/goblins.atlas')
     self.names = sorted(self.a.region_lib.keys())
     self.i = 17
     print self.names[self.i]
     self.sprite = sprite.Sprite(self.a.get_attachment_region(self.names[self.i]))
     #self.sprite.scale_x = 0.5
     #self.sprite.scale_y = 0.25
     self.b = Box(self.sprite.get_rect(), red)
     self.sprite.add(self.b)
     self.sprite.position = (512, 512)
     self.add(self.sprite, z=1)
     self.add(b, z=1)