I wrote a party game using the Scene module that involves passing my phone around a lot. Someone inevitably pushes the corner 'X', which quits the game early. I haven't been able to see where to change this behavior. Much of the scene code is hidden in the _scene module. Any suggestions? I'm fine with having no exit for the game (force close the whole app to quit).
Forum Archive
Override Scene exit button
cjchallis
Jan 02, 2016 - 15:34
ccc
Jan 02, 2016 - 17:33
import scene, ui
class UnclosableScene(ui.View):
def __init__(self, the_scene):
scene_view = scene.SceneView()
scene_view.scene = the_scene
self.present(hide_title_bar=True)
scene_view.frame = self.bounds
self.add_subview(scene_view)
class BlueScene(scene.Scene):
def __init__(self):
self.background_color = 'midnightblue'
UnclosableScene(BlueScene())
A two fingered swipe down will shutdown the scene.
cjchallis
Jan 02, 2016 - 19:54
Thanks! I'll experiment with this and try to integrate it with my existing code.
Webmaster4o
Jan 02, 2016 - 20:38
Clever solution, @ccc
cjchallis
Jan 02, 2016 - 22:23
This worked great! Just one more question - I haven't worked with Pythonista's ui before, how do I keep the view from rotating? I'd like to keep it fixed in landscape.
Nevermind - I added 'orientation = ['landscape]' as an argument to 'self.present'. Problem solved.