Created
August 21, 2016 11:42
-
-
Save Mr-Coxall/064dcc9494056e046d28cc6470884f14 to your computer and use it in GitHub Desktop.
scene_test.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
# 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