Skip to content

Instantly share code, notes, and snippets.

@Mr-Coxall
Created August 21, 2016 11:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mr-Coxall/064dcc9494056e046d28cc6470884f14 to your computer and use it in GitHub Desktop.
Save Mr-Coxall/064dcc9494056e046d28cc6470884f14 to your computer and use it in GitHub Desktop.
scene_test.py
# for use with https://github.com/omz/PythonistaAppTemplate
from scene import *
import ui
class FirstScene (Scene):
def setup(self):
self.background_color = 'midnightblue'
self.ship = SpriteNode('spc:PlayerShip1Orange')
self.ship.position = self.size / 2
self.add_child(self.ship)
def touch_began(self, touch):
# question?
# how do you get to the second scene?
self.present_modal_scene(my_second_scene)
class SecondScene (Scene):
def setup(self):
self.background_color = '#704414'
self.ship = SpriteNode('spc:EnemyGreen2')
self.ship.position = self.size / 2
self.add_child(self.ship)
def touch_began(self, touch):
pass
my_scene = FirstScene()
my_second_scene = SecondScene()
# Instead of...
# run(MyScene())
# ..use:
main_view = ui.View()
scene_view = SceneView(frame=main_view.bounds, flex='WH')
main_view.add_subview(scene_view)
scene_view.scene = my_scene
main_view.present(hide_title_bar=True, animated=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment