I've been learning Bevy and I can't figure out how to simply rotate a sprite.
Here is a minimal example illustrating what appears to be a correctly rotated square but an incorrectly rotated rectangle with one dependency bevy = "0.6.1"
and main.rs
:
use bevy::prelude::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_startup_system(setup)
.run();
}
fn setup(mut commands: Commands) {
// cameras
commands.spawn_bundle(OrthographicCameraBundle::new_2d());
// square
commands.spawn_bundle(SpriteBundle {
transform: Transform {
translation: Vec3::from((0f32, 0f32, 0f32)),
rotation: Quat::from_rotation_z(2f32),
scale: Vec3::new(100f32, 100f32, 0f32),
},
sprite: Sprite {
color: Color::rgb(1., 1., 1.),
..Default::default()
},
..Default::default()
});
// line
commands.spawn_bundle(SpriteBundle {
transform: Transform {
translation: Vec3::from((0f32, 200f32, 0f32)),
rotation: Quat::from_rotation_z(2f32),
scale: Vec3::new(100f32, 10f32, 0f32),
},
sprite: Sprite {
color: Color::rgb(1., 1., 1.),
..Default::default()
},
..Default::default()
});
}
How could I properly rotate the rectangle?
(I've read How to rotate and move object in bevy and I cannot see how it might answer my problem)