Created
November 5, 2014 16:56
-
-
Save ShambhalaLogan/5a762c22d4f4037a8f0e to your computer and use it in GitHub Desktop.
ui.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from scene import * | |
import ui, random, scene | |
class MyScene (Scene): | |
def setup(self): | |
self.Pos = [50, 50] | |
def draw(self): | |
background(0, 0, 0) | |
self.Pos[0] += random.randint(-2, 2) | |
self.Pos[1] += random.randint(-2, 2) | |
fill(1, 1, 1) | |
ellipse(self.Pos[0], self.Pos[1], 2, 2) | |
text('If this isn\'t moving,\nthen the Scene is paused.', 'Arial', 12, self.Pos[0]+2, self.Pos[1]+2, 9) | |
text('Tap here to open another UI view.\nDrag down with 2 fingers to close.', 'Arial', 16, 0, 0, 9) | |
def touch_began(self, touch): | |
if touch.location.y < 50: | |
ui.View().present() | |
else: | |
self.Pos = [touch.location.x, touch.location.y] | |
class SceneViewer(ui.View): | |
def __init__(self, in_scene): | |
self.present('full_screen', hide_title_bar = True) | |
scene_view = scene.SceneView(frame=self.frame) | |
scene_view.scene = in_scene | |
self.add_subview(scene_view) | |
SceneViewer(MyScene()) |
cclauss
commented
Nov 7, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment