| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
use bevy::camera_controller::pan_camera::{PanCamera, PanCameraPlugin}; |
| 13 |
use bevy::prelude::*; |
| 14 |
|
| 15 |
fn main() { |
| 16 |
App::new() |
| 17 |
.add_plugins(DefaultPlugins) |
| 18 |
.add_plugins(PanCameraPlugin) |
| 19 |
.add_systems(Startup, (setup, spawn_text).chain()) |
| 20 |
.run(); |
| 21 |
} |
| 22 |
|
| 23 |
fn spawn_text(mut commands: Commands, camera: Query<&PanCamera>) { |
| 24 |
commands.spawn(( |
| 25 |
Node { |
| 26 |
position_type: PositionType::Absolute, |
| 27 |
top: px(-16), |
| 28 |
left: px(12), |
| 29 |
..default() |
| 30 |
}, |
| 31 |
children![Text::new(format!("{}", camera.single().unwrap()))], |
| 32 |
)); |
| 33 |
} |
| 34 |
|
| 35 |
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) { |
| 36 |
|
| 37 |
commands.spawn((Camera2d, PanCamera::default())); |
| 38 |
|
| 39 |
commands.spawn(Sprite::from_image( |
| 40 |
asset_server.load("branding/bevy_bird_dark.png"), |
| 41 |
)); |
| 42 |
} |