Replies: 2 comments 1 reply
-
I found this detailed documentation for Godot https://docs.godotengine.org/en/stable/tutorials/rendering/multiple_resolutions.html Does bevy's window have any of these features? |
Beta Was this translation helpful? Give feedback.
1 reply
-
Thingoln suggested this in the discord: fn resize_window(
mut commands: Commands,
mut projection: Query<Entity, With<OrthographicProjection>>,
mut resize_event: EventReader<WindowResized>
) {
match resize_event.iter().next() {
Some(w) => {
let mut projection = projection.single_mut();
commands.entity(projection).despawn();
let mut camera = OrthographicCameraBundle::new_2d();
camera.orthographic_projection.scale = max(WINDOW_HEIGHT / w.height, WINDOW_WIDTH / w.width);
commands.spawn_bundle(camera);
},
None => ()
};
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello I am making the game pong. I was wondering how 2d games handle different sized windows. What are the best practices in regards to a single screen game like pong where I have a static camera and I want everything to be visible at once. How should I positioning and size elements in the game? Currently I am doing this through the window height and width but this seems like a bad idea. Different sized windows would affect gameplay.
In the case of pong we want the ball to bounce of the edges of the screen. However different sized screens will cause the ball to bounce in different ways. I could disable window resizing but what if I wanted to make the game full screen? Does bevy have an easy way of dealing with these problems? What are the best solutions?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions