Created
September 10, 2016 13:13
-
-
Save Mr-Coxall/b9bc5316114468f113eb0b86a63fa2c0 to your computer and use it in GitHub Desktop.
card_scene.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 | |
from menu_scene import * | |
class CardBackScene(Scene): | |
def __init__(self, card_back_color='blue'): | |
Scene.__init__(self) | |
self.img_name = 'card:Back{}1'.format(card_back_color.title()) | |
def setup(self): | |
# add background color | |
SpriteNode(anchor_point=(0, 0), color='white', parent=self, | |
size=self.size) | |
self.card = SpriteNode(self.img_name, parent=self, | |
position=self.size/2) | |
def touch_ended(self, touch): | |
# moving back to previous scene, so remove modal makes sense | |
if self.card.frame.contains_point(touch.location): | |
self.dismiss_modal_scene() |
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 | |
import time | |
from menu_scene import * | |
class CompanyScene(Scene): | |
def setup(self): | |
self.start_time = time.time() | |
# add background color | |
SpriteNode(anchor_point=(0, 0), color='green', parent=self, | |
size=self.size) | |
self.ship = SpriteNode('spc:EnemyRed3', parent=self, | |
position=self.size/2) | |
def update(self): | |
if not self.presented_scene and time.time() - self.start_time > 2: | |
self.present_modal_scene(MenuScene()) | |
pass | |
def touch_began(self, touch): | |
pass | |
def touch_ended(self, touch): | |
if self.ship.frame.contains_point(touch.location): | |
self.present_modal_scene(MenuScene()) | |
pass |
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 | |
import time | |
from company_scene import CompanyScene | |
class SplashScene(Scene): | |
def setup(self): | |
# get starting time | |
self.start_time = time.time() | |
# add background color | |
SpriteNode(anchor_point=(0, 0), color='white', parent=self, | |
size=self.size) | |
self.ship = SpriteNode('test:Pythonista', anchor_point=(0, 0), | |
parent=self, size=self.size) | |
def update(self): | |
# move to new scene after 2 seconds | |
if not self.presented_scene and time.time() - self.start_time > 2: | |
self.present_modal_scene(CompanyScene()) | |
def touch_began(self, touch): | |
# self.present_modal_scene(SecondScene()) | |
pass | |
def touch_ended(self, touch): | |
if self.ship.frame.contains_point(touch.location): | |
self.present_modal_scene(SecondScene()) | |
#. .. use while developing | |
main_view = SceneView() | |
main_view.scene = SplashScene() | |
main_view.present(hide_title_bar=True, animated=False) | |
# ..use when deploying app to Xcode | |
#main_view = ui.View() | |
#scene_view = SceneView(frame=main_view.bounds, flex='WH') | |
#main_view.add_subview(scene_view) | |
#scene_view.scene = FirstScene() | |
#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