Проектная работа - WIP
голова змеи и ее вращение
This commit is contained in:
@@ -22,51 +22,44 @@ fn main() {
|
||||
.insert_resource(WinitSettings::desktop_app())
|
||||
.insert_resource(ClearColor(Color::srgb(0.3, 0.6, 0.8)))
|
||||
.add_systems(Startup, setup)
|
||||
.add_systems(PostStartup, print_all_entities)
|
||||
.add_systems(PostStartup, (print_all_entities, inspect))
|
||||
.run();
|
||||
}
|
||||
|
||||
fn setup(mut commands: Commands, _window: Query<&Window>) {
|
||||
fn setup(mut commands: Commands, _window: Query<&Window>, _world: &World) {
|
||||
let _window = _window.single().unwrap();
|
||||
// trace!("window: {:?}", window.single());
|
||||
|
||||
let _root = commands
|
||||
.spawn((
|
||||
Sprite::from_color(Color::srgb(1., 1., 1.), Vec2::new(100., 100.)),
|
||||
Transform {
|
||||
translation: vec3(0., 0., 0.),
|
||||
// scale: Vec3::new(1., 1., 1.),
|
||||
..Default::default()
|
||||
},
|
||||
))
|
||||
.id();
|
||||
let _red = commands
|
||||
.spawn((
|
||||
Sprite::from_color(Color::srgb(1., 0., 0.), Vec2::new(30., 30.)),
|
||||
Transform {
|
||||
translation: vec3(-20., 30., 1.),
|
||||
translation: vec3(-20., 30., 0.),
|
||||
..Default::default()
|
||||
},
|
||||
// ChildOf(_root),
|
||||
ChildOf(_root),
|
||||
))
|
||||
.id();
|
||||
let _blue = commands
|
||||
.spawn((
|
||||
Sprite::from_color(Color::srgb(0., 0., 1.), Vec2::new(20., 20.)),
|
||||
Transform {
|
||||
translation: vec3(20., 30., 1.),
|
||||
translation: vec3(20., 30., 0.),
|
||||
..Default::default()
|
||||
},
|
||||
// ChildOf(_root),
|
||||
ChildOf(_root),
|
||||
))
|
||||
.id();
|
||||
|
||||
let x = -_window.resolution.width() / 2. + 52.;
|
||||
let y = -_window.resolution.height() / 2. + 52.;
|
||||
let _root = commands
|
||||
.spawn((
|
||||
Sprite::from_color(Color::srgb(1., 1., 1.), Vec2::new(100., 100.)),
|
||||
Transform {
|
||||
translation: vec3(x, y, 1.),
|
||||
// scale: Vec3::new(1., 1., 1.),
|
||||
..Default::default()
|
||||
},
|
||||
))
|
||||
.id();
|
||||
|
||||
commands.entity(_red).insert(ChildOf(_root));
|
||||
commands.entity(_blue).insert(ChildOf(_root));
|
||||
|
||||
commands.spawn(Camera2d);
|
||||
}
|
||||
|
||||
@@ -75,3 +68,5 @@ fn print_all_entities(mut commands: Commands, query: Query<Entity>) {
|
||||
commands.entity(entity).log_components();
|
||||
}
|
||||
}
|
||||
|
||||
fn inspect(mut _commands: Commands, _query: Query<Entity>) {}
|
||||
|
||||
Reference in New Issue
Block a user