Forum Archive

Switching to SceneView zooms in Scene?

techteej

I used the code below to change a scene into a Scene View (launched by a button in a UI Menu), and it seems that the game scene is zoomed in. It also cuts off the scene and does not fill the entire screen.

w, h = ui.get_screen_size()
root_view = ui.View('menu')
scene_view = scene.SceneView()
scene_view.frame = (0, 0, w, h)
scene_view.scene = Game()

Problem

dgelessus

ui.get_screen_size() returns the full screen resolution for portrait mode, no matter how the device is rotated. The best way to make a view fill the entire screen is to set the view's flex = "WH".

techteej

Setting the view's flex = "WH" doesn't do anything.

ccc

This works for me...

#w, h = ui.get_screen_size()
root_view = ui.View('menu')
scene_view = scene.SceneView()
#scene_view.frame = (0, 0, w, h)
scene_view.flex = 'WH'
scene_view.scene = Game()

For another approach, see SceneViewer: http://omz-forums.appspot.com/pythonista/post/6096598232727552

techteej

Using

#w, h = ui.get_screen_size()
root_view = ui.View('menu')
scene_view = scene.SceneView()
#scene_view.frame = (0, 0, w, h)
scene_view.flex = 'WH'
scene_view.scene = Game()

Gives Me

alt text

ccc

Are you doing root_view.add_subview(scene_view)?

techteej

Yes!

techteej

Tried this on another script, it still happened there too.

ccc

AFTER you present the root_view, do scene_view = scene.SceneView(frame=root_view.frame).

techteej

This gives me a black screen.

ccc

Did you set scene_view.scene AFTER the line above?

techteej

Got it working now, thanks.

techteej

This is now happening to me in only Xcode 6.1, But works fine in Pythonista. Really wishing I never updated Xcode. Haven't stopped getting problems ever since.

techteej

Any ideas?

ccc

Can you please post a github repo of a minimum codebase that exhibits this behavior?

techteej

@ccc See here.

JonB

Techteej, it would be helpful if you post a complete working example.
By complete, that means someone should be able to run your code, as is, without having to guess what your are doing.
Given that you didn't post your pyui, and given that there are some variables (offset) which are never defined in your code, no one here can possibly help you.

techteej

@JonB not much info had to be given to describe the problem, but here's everything https://gist.github.com/tjferry14/30f0fd54c05071240559

JonB

Can you repost the picture of what is happening? The imgur link is invalid

techteej

When ran in Xcode, the scene is just a black screen.

JonB

Ok, so to be clear....... With your original code, you saw something, but it was the wrong size. Now you see only black?
Does the menu work?
You might want to go way back to basics - can you get a simple scene which, say, draws a colored rectangle on the screen to work in a sceneview? I.e rule out any problems with loading images, etc.

techteej

The menu works just fine, but when tapping play game (to load the scene) I get a black screen

JonB

So once again...in your original code, did you get a black screen?

Can you see ANY sceneview. .. Try a simple one without images, since paths always seem to be an issue....