Crates.io | bevy_mod_2d_hierarchy |
lib.rs | bevy_mod_2d_hierarchy |
version | 0.3.1 |
source | src |
created_at | 2022-11-03 15:57:23.144931 |
updated_at | 2022-12-24 11:33:02.144604 |
description | Bevy plugin for more ergonomic 2d. |
homepage | |
repository | https://github.com/ickshonpe/bevy_mod_2d_hierarchy |
max_upload_size | |
id | 704346 |
size | 125,189 |
Bevy plugin for more ergonomic 2D.
GlobalTransform
and not Transform
.Add the dependency to your Cargo.toml
[dependencies]
bevy_mod_2d_hierarchy = "0.3"
Add the plugin to your Bevy App:
use bevy::prelude::*;
use bevy_mod_2d_hierarachy::prelude::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugin(Transform2dPlugin)
// .. rest of systems etc
.run();
}
Then spawn some sprites
pub fn spawn(
mut commands: Commands,
asset_server: Res<AssetServer>,
) {
commands.spawn(Camera2dBundle2::default());
commands.spawn(SpriteBundle2 {
texture: asset_server.load("sprite.png"),
transform2: Transform2::from_rotation(0.5 * PI).with_scale(3.),
..Default::default()
})
.with_children(|builder| {
builder.spawn(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()
});
});
}
See also: https://github.com/devil-ira/bevy_mod_transform2d.
Major differences Transform2d vs 2d_hierarchy:
You could even use Transform2d and 2d_hierarchy together if you really wanted. That would be really silly though.