ccc
Jul 29, 2014 - 13:29
When you want to use both the ui and scene modules together, SceneViewer can act as a plug-compatible replacement for scene.run(). Of course, scene.gravity() no longer works but more on that in a follow up post.
In your code, replace:
scene.run(MyScene())
#with...
import ui
SceneViewer(MyScene())
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)
self.add_subview(self.close_button())
def close_action(self, sender):
self.close()
def close_button(self):
the_button = ui.Button(title='X')
the_button.x = self.width - the_button.width
the_button.y = the_button.height / 2
the_button.action = self.close_action
the_button.font=('<system-bold>', 20)
return the_button