This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Feb 23rd, 2012  |  syntax: Python  |  size: 0.98 KB  |  views: 31  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import pyglet
  2. pyglet.options['graphics_vbo'] = False
  3. from cocos.sprite import Sprite
  4. from cocos.layer import Layer
  5. from cocos.scene import Scene
  6. from cocos.director import director
  7.  
  8. import Image
  9. im = Image.new('RGBA', (200, 200), (150, 150, 150, 255))
  10. im.save('grey.png', 'PNG')
  11. im = Image.new('RGBA', (100, 100), (255, 0, 0, 0))
  12. im.save('alpha_red.png', 'PNG')
  13. im = Image.new('RGBA', (80, 80), (0, 255, 0, 255))
  14. im.save('green.png', 'PNG')
  15.  
  16. class Spt(Sprite):
  17.  
  18.     def __init__(self):
  19.         super(Spt ,self).__init__('alpha_red.png')
  20.         s = Sprite('green.png')
  21.         self.add(s, z=2)
  22.  
  23. class Layer1(Layer):
  24.  
  25.     def __init__(self):
  26.         super(Layer1 ,self).__init__()
  27.         s = Sprite('grey.png')
  28.         self.add(s)
  29.         s.position = 300, 300
  30.         alpha = Spt()
  31.         self.add(alpha, z=2)
  32.         alpha.position = 300, 300
  33.  
  34.  
  35. if __name__ == '__main__':
  36.     director.init(width=900, height=900)
  37.     scene1 = Scene(Layer1())
  38.     director.run(scene1)
clone this paste RAW Paste Data