Bevy plugin for more ergonomic 2D.
GlobalTransform
and not Transform
.Add the dependency to your Cargo.toml
toml
[dependencies]
bevy_mod_2d_hierarchy = "0.2"
Add the plugin to your Bevy App: ```rust use bevy::prelude::; use bevy_mod_2d_hierarachy::prelude::;
fn main() { App::new() .addplugins(DefaultPlugins) .addplugin(Transform2dPlugin) // .. rest of systems etc .run(); } ```
Then spawn some sprites
rust
pub fn spawn(
mut commands: Commands,
asset_server: Res<AssetServer>,
) {
commands.spawn_bundle(Camera2dBundle2::default());
commands.spawn_bundle(SpriteBundle2 {
texture: asset_server.load("sprite.png"),
transform2: Transform2::from_rotation(0.5 * std::f32::consts::PI).with_scale(3.),
..Default::default()
})
.with_children(|builder| {
builder.spawn_bundle(SpriteBundle2 {
sprite: Sprite { color: Color::YELLOW, ..Default::default() },
texture: asset_server.load("sprite.png"),
transform2: Transform2::from_xy(0., 32.),
propagate: Propagate::TRANSLATION,
..Default::default()
});
});
}