How to split window #8754
-
I want to display score or something on the window. Sprites should not go to the position where score text displayed otherwise the overlap will occur. Is there a method to split the window just like below? Or should I just create a new window? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
You need two cameras with two different viewports. Here is an example how to do that: |
Beta Was this translation helpful? Give feedback.
-
So in Bevy, rather than creating multiple windows, you can use a single window with two cameras, each assigned a different viewport. To manage where sprites can move within each split screen, you can access the physical_size of the camera’s viewport (via camera.viewport.physical_size) and use that to constrain sprite movement—much cleaner than trying to manage separate windows or guessing boundaries. |
Beta Was this translation helpful? Give feedback.
You need two cameras with two different viewports.
Here is an example how to do that:
https://github.com/bevyengine/bevy/blob/main/examples/3d/split_screen.rs