diff --git a/examples/camera_scaling_mode.rs b/examples/camera_scaling_mode.rs index f6a65d7..4e49d75 100644 --- a/examples/camera_scaling_mode.rs +++ b/examples/camera_scaling_mode.rs @@ -4,17 +4,18 @@ use rand::prelude::random; fn main() { App::new() - .add_plugins((DefaultPlugins, PanCamPlugin::default())) + .add_plugins((DefaultPlugins, PanCamPlugin)) .add_systems(Startup, setup) .run(); } fn setup(mut commands: Commands) { - let mut cam = Camera2dBundle::default(); - cam.projection.scaling_mode = ScalingMode::FixedVertical(10.0); + let mut ortho = OrthographicProjection::default_2d(); + ortho.scaling_mode = ScalingMode::FixedVertical { viewport_height: 10.0 }; commands.spawn(( - cam, + Camera2d, + ortho, PanCam { min_x: -10., max_x: 10., @@ -33,15 +34,14 @@ fn setup(mut commands: Commands) { let x = x as f32 * spacing + offset; let y = y as f32 * spacing + offset; let color = Color::hsl(240., random::() * 0.3, random::() * 0.3); - commands.spawn(SpriteBundle { - sprite: Sprite { + commands.spawn(( + Sprite { color, custom_size, ..default() }, - transform: Transform::from_xyz(x, y, 0.), - ..default() - }); + Transform::from_xyz(x, y, 0.), + )); } } } diff --git a/examples/clamped_borders.rs b/examples/clamped_borders.rs index c837959..c471a39 100644 --- a/examples/clamped_borders.rs +++ b/examples/clamped_borders.rs @@ -4,14 +4,14 @@ use rand::prelude::random; fn main() { App::new() - .add_plugins((DefaultPlugins, PanCamPlugin::default())) + .add_plugins((DefaultPlugins, PanCamPlugin)) .add_systems(Startup, setup) .run(); } fn setup(mut commands: Commands) { commands.spawn(( - Camera2dBundle::default(), + Camera2d, PanCam { // prevent the camera from zooming too far out max_scale: 40., @@ -40,15 +40,14 @@ fn setup(mut commands: Commands) { let x = x as f32 * spacing - offset; let y = y as f32 * spacing - offset; let color = Color::hsl(240., random::() * 0.3, random::() * 0.3); - commands.spawn(SpriteBundle { - sprite: Sprite { + commands.spawn(( + Sprite { color, custom_size, ..default() }, - transform: Transform::from_xyz(x, y, 0.), - ..default() - }); + Transform::from_xyz(x, y, 0.), + )); } } } diff --git a/examples/egui.rs b/examples/egui.rs index 1123ca9..e5288f4 100644 --- a/examples/egui.rs +++ b/examples/egui.rs @@ -8,7 +8,7 @@ use rand::random; fn main() { App::new() - .add_plugins((DefaultPlugins, PanCamPlugin::default(), EguiPlugin)) + .add_plugins((DefaultPlugins, PanCamPlugin, EguiPlugin)) .add_systems(Update, egui_ui) .add_systems(Startup, setup) .run(); @@ -33,7 +33,7 @@ fn egui_ui(mut contexts: EguiContexts) { } fn setup(mut commands: Commands) { - commands.spawn((Camera2dBundle::default(), PanCam::default())); + commands.spawn((Camera2d, PanCam::default())); let n = 20; let spacing = 50.; @@ -44,15 +44,14 @@ fn setup(mut commands: Commands) { let x = x as f32 * spacing - offset; let y = y as f32 * spacing - offset; let color = Color::hsl(240., random::() * 0.3, random::() * 0.3); - commands.spawn(SpriteBundle { - sprite: Sprite { + commands.spawn(( + Sprite { color, custom_size, ..default() }, - transform: Transform::from_xyz(x, y, 0.), - ..default() - }); + Transform::from_xyz(x, y, 0.), + )); } } } diff --git a/examples/inspector.rs b/examples/inspector.rs index 99a0b4e..df495a4 100644 --- a/examples/inspector.rs +++ b/examples/inspector.rs @@ -7,15 +7,15 @@ fn main() { App::new() .add_plugins(( DefaultPlugins, - PanCamPlugin::default(), - WorldInspectorPlugin::default(), + PanCamPlugin, + WorldInspectorPlugin::new(), )) .add_systems(Startup, setup) .run(); } fn setup(mut commands: Commands) { - commands.spawn((Camera2dBundle::default(), PanCam::default())); + commands.spawn((Camera2d, PanCam::default())); let n = 20; let spacing = 50.; @@ -26,15 +26,14 @@ fn setup(mut commands: Commands) { let x = x as f32 * spacing - offset; let y = y as f32 * spacing - offset; let color = Color::hsl(240., random::() * 0.3, random::() * 0.3); - commands.spawn(SpriteBundle { - sprite: Sprite { + commands.spawn(( + Sprite { color, custom_size, ..default() }, - transform: Transform::from_xyz(x, y, 0.), - ..default() - }); + Transform::from_xyz(x, y, 0.), + )); } } } diff --git a/examples/limits.rs b/examples/limits.rs index dab0bbe..c8c82b9 100644 --- a/examples/limits.rs +++ b/examples/limits.rs @@ -4,14 +4,14 @@ use rand::prelude::random; fn main() { App::new() - .add_plugins((DefaultPlugins, PanCamPlugin::default())) + .add_plugins((DefaultPlugins, PanCamPlugin)) .add_systems(Startup, setup) .run(); } fn setup(mut commands: Commands) { commands.spawn(( - Camera2dBundle::default(), + Camera2d, PanCam { // Set max scale in order to prevent the camera from zooming too far out max_scale: 40., @@ -30,15 +30,14 @@ fn setup(mut commands: Commands) { let x = x as f32 * spacing - offset; let y = y as f32 * spacing - offset; let color = Color::hsl(240., random::() * 0.3, random::() * 0.3); - commands.spawn(SpriteBundle { - sprite: Sprite { + commands.spawn(( + Sprite { color, custom_size, ..default() }, - transform: Transform::from_xyz(x, y, 0.), - ..default() - }); + Transform::from_xyz(x, y, 0.), + )); } } } diff --git a/examples/simple.rs b/examples/simple.rs index 9e8f428..4c906a1 100644 --- a/examples/simple.rs +++ b/examples/simple.rs @@ -4,13 +4,13 @@ use rand::prelude::random; fn main() { App::new() - .add_plugins((DefaultPlugins, PanCamPlugin::default())) + .add_plugins((DefaultPlugins, PanCamPlugin)) .add_systems(Startup, setup) .run(); } fn setup(mut commands: Commands) { - commands.spawn((Camera2dBundle::default(), PanCam::default())); + commands.spawn((Camera2d, PanCam::default())); let n = 20; let spacing = 50.; @@ -21,15 +21,14 @@ fn setup(mut commands: Commands) { let x = x as f32 * spacing - offset; let y = y as f32 * spacing - offset; let color = Color::hsl(240., random::() * 0.3, random::() * 0.3); - commands.spawn(SpriteBundle { - sprite: Sprite { + commands.spawn(( + Sprite { color, custom_size, ..default() }, - transform: Transform::from_xyz(x, y, 0.), - ..default() - }); + Transform::from_xyz(x, y, 0.), + )); } } } diff --git a/examples/toggle.rs b/examples/toggle.rs index 1535c38..e6fe594 100644 --- a/examples/toggle.rs +++ b/examples/toggle.rs @@ -4,14 +4,14 @@ use rand::prelude::random; fn main() { App::new() - .add_plugins((DefaultPlugins, PanCamPlugin::default())) + .add_plugins((DefaultPlugins, PanCamPlugin)) .add_systems(Startup, setup) .add_systems(Update, toggle_key) .run(); } fn setup(mut commands: Commands) { - commands.spawn((Camera2dBundle::default(), PanCam::default())); + commands.spawn((Camera2d, PanCam::default())); let n = 20; let spacing = 50.; @@ -22,15 +22,14 @@ fn setup(mut commands: Commands) { let x = x as f32 * spacing - offset; let y = y as f32 * spacing - offset; let color = Color::hsl(240., random::() * 0.3, random::() * 0.3); - commands.spawn(SpriteBundle { - sprite: Sprite { + commands.spawn(( + Sprite { color, custom_size, ..default() }, - transform: Transform::from_xyz(x, y, 0.), - ..default() - }); + Transform::from_xyz(x, y, 0.), + )); } } } diff --git a/examples/viewport.rs b/examples/viewport.rs index 67bc206..8237317 100644 --- a/examples/viewport.rs +++ b/examples/viewport.rs @@ -1,25 +1,22 @@ use bevy::{prelude::*, render::camera::Viewport}; use bevy_pancam::{PanCam, PanCamPlugin}; -use rand::prelude::random; fn main() { App::new() - .add_plugins((DefaultPlugins, PanCamPlugin::default())) + .add_plugins((DefaultPlugins, PanCamPlugin)) .add_systems(Startup, setup) .run(); } fn setup(mut commands: Commands) { commands.spawn(( - Camera2dBundle { - camera: Camera { - viewport: Some(Viewport { - physical_position: UVec2::new(100, 200), - physical_size: UVec2::new(600, 400), - depth: 0.0..1.0, - }), - ..Camera2dBundle::default().camera - }, + Camera2d, + Camera { + viewport: Some(Viewport { + physical_position: UVec2::new(100, 200), + physical_size: UVec2::new(600, 400), + depth: 0.0..1.0, + }), ..default() }, PanCam { @@ -32,24 +29,22 @@ fn setup(mut commands: Commands) { )); // background - commands.spawn(SpriteBundle { - sprite: Sprite { + commands.spawn(( + Sprite { color: Color::srgb(0.3, 0.3, 0.3), custom_size: Some(Vec2::new(1000., 1000.)), ..default() }, - transform: Transform::from_xyz(0., 0., 0.), - ..default() - }); + Transform::from_xyz(0., 0., 0.), + )); // red square - commands.spawn(SpriteBundle { - sprite: Sprite { + commands.spawn(( + Sprite { color: Color::srgb(0.8, 0.3, 0.3), custom_size: Some(Vec2::new(100., 100.)), ..default() }, - transform: Transform::from_xyz(0., 0., 1.), - ..default() - }); + Transform::from_xyz(0., 0., 1.), + )); }