use bevy::prelude::*; use bevy_dolly::prelude::*; fn main() { App::new() .add_plugins(DefaultPlugins) .add_systems(Startup, setup) .add_systems( Update, ( Dolly::::update_2d_active, update_camera, sprite_movement, ), ) .run(); } #[derive(Component)] struct MainCamera; #[derive(Component)] enum Direction { Left, Right, } fn setup(mut commands: Commands, asset_server: Res) { commands .spawn(SpriteBundle { texture: asset_server.load("bevy_dolly.png"), transform: Transform::from_xyz(100., 0., 0.1), sprite: Sprite { custom_size: Some(Vec2::new(128., 128.)), ..Default::default() }, ..Default::default() }) .insert(Direction::Right); commands.spawn(SpriteBundle { texture: asset_server.load("room.png"), transform: Transform::from_xyz(100., 200., 0.), sprite: Sprite { custom_size: Some(Vec2::new(2.6 * 800., 800.)), ..Default::default() }, ..Default::default() }); commands.spawn(SpriteBundle { texture: asset_server.load("room_end.png"), transform: Transform::from_xyz(1116., -104.5, 0.2), sprite: Sprite { ..Default::default() }, ..Default::default() }); commands.spawn(SpriteBundle { texture: asset_server.load("room_end.png"), transform: Transform::from_xyz(-916., -104.5, 0.2), sprite: Sprite { flip_x: true, ..Default::default() }, ..Default::default() }); commands.spawn(( MainCamera, Rig::builder() .with(Position::new(Vec3::new(0., 0., 0.))) .with(Smooth::new_position(1.2)) .build(), Camera2dBundle::default(), )); } /// The sprite is animated by changing its translation depending on the time that has passed since /// the last frame. fn sprite_movement(time: Res