diff --git a/Cargo.toml b/Cargo.toml index 9e0b659358b7c..95df03bd94e2a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -119,6 +119,10 @@ path = "examples/2d/contributors.rs" name = "many_sprites" path = "examples/2d/many_sprites.rs" +[[example]] +name = "move_sprite" +path = "examples/2d/move_sprite.rs" + [[example]] name = "2d_rotation" path = "examples/2d/rotation.rs" diff --git a/examples/2d/move_sprite.rs b/examples/2d/move_sprite.rs new file mode 100644 index 0000000000000..1163d7ce5fbd2 --- /dev/null +++ b/examples/2d/move_sprite.rs @@ -0,0 +1,41 @@ +use bevy::prelude::*; + +fn main() { + App::new() + .add_plugins(DefaultPlugins) + .add_startup_system(setup) + .add_system(sprite_movement) + .run(); +} + +#[derive(Component)] +enum Direction { + Up, + Down, +} + +fn setup(mut commands: Commands, asset_server: Res) { + commands.spawn_bundle(OrthographicCameraBundle::new_2d()); + commands + .spawn_bundle(SpriteBundle { + texture: asset_server.load("branding/icon.png"), + transform: Transform::from_xyz(100., 0., 0.), + ..Default::default() + }) + .insert(Direction::Up); +} + +fn sprite_movement(time: Res