Skip to content

Instantly share code, notes, and snippets.

@C0deH4cker
Created December 2, 2012 03:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save C0deH4cker/a066691269d63ddc0d4c to your computer and use it in GitHub Desktop.
Save C0deH4cker/a066691269d63ddc0d4c to your computer and use it in GitHub Desktop.
Image_Example
from scene import *
from random import random
class MyScene (Scene):
def setup(self):
# This will be called before the first frame is drawn.
# Set up the root layer and one other layer:
self.root_layer = Layer(self.bounds)
center = self.bounds.center()
self.layer = Layer(Rect(center.x - 64, center.y - 64, 128, 128))
self.layer.image = 'Snake'
self.root_layer.add_layer(self.layer)
def draw(self):
# Update and draw our root layer. For a layer-based scene, this
# is usually all you have to do in the draw method.
background(0, 0, 0)
self.root_layer.update(self.dt)
self.root_layer.draw()
def touch_began(self, touch):
self.layer.animate('rotation', self.layer.rotation + 90)
def touch_moved(self, touch):
pass
def touch_ended(self, touch):
pass
run(MyScene())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment