UI launching a scene
I have made a game (which I have posted about before) using the
I am trying to get a pyui file to launch the scene. After some trial and error I managed it like this:
import ui from black_white import * from time import sleep from scene import run @ui.in_background def start(sender): run(Game(), show_fps=False) v = ui.load_view() v.present('sheet', hide_title_bar = True)
black_whiteis the name of the script running my scene
I could only get it to work by running the scene 'inside' the UI. I had to import
scene.runas my script needs them, which seems quite messy. When I try to close the UI view
vat the end of the
startfunction, everything closes!
Does anyone know of a better way to do this?
You might be able to use a SceneView. Maybe it's just me, but I couldn't understand your question clearly. So this might not be the answer. But oh well.
You can create a SceneView:
sv = ui.SceneView()
Add your scene as a parameter of "sv", then use
in your function.
Your button calls the function, the just clear the main_view and call the line above.
Here you can find an example PhotoTextV2.
It's a ui.View with two scrollviews. One for buttons and another one for the scene.SceneView.
edit: Have you tried ui.delay instead of time.sleep?