Add quad to 2d_shapes example (#7708)

# Objective

- Add quad to 2d_shapes example
This commit is contained in:
张林伟 2023-02-17 01:50:20 +00:00
parent db2fd92385
commit 1f6bbc6b7a

View File

@ -16,6 +16,14 @@ fn setup(
) { ) {
commands.spawn(Camera2dBundle::default()); commands.spawn(Camera2dBundle::default());
// Circle
commands.spawn(MaterialMesh2dBundle {
mesh: meshes.add(shape::Circle::new(50.).into()).into(),
material: materials.add(ColorMaterial::from(Color::PURPLE)),
transform: Transform::from_translation(Vec3::new(-150., 0., 0.)),
..default()
});
// Rectangle // Rectangle
commands.spawn(SpriteBundle { commands.spawn(SpriteBundle {
sprite: Sprite { sprite: Sprite {
@ -23,14 +31,17 @@ fn setup(
custom_size: Some(Vec2::new(50.0, 100.0)), custom_size: Some(Vec2::new(50.0, 100.0)),
..default() ..default()
}, },
transform: Transform::from_translation(Vec3::new(-50., 0., 0.)),
..default() ..default()
}); });
// Circle // Quad
commands.spawn(MaterialMesh2dBundle { commands.spawn(MaterialMesh2dBundle {
mesh: meshes.add(shape::Circle::new(50.).into()).into(), mesh: meshes
material: materials.add(ColorMaterial::from(Color::PURPLE)), .add(shape::Quad::new(Vec2::new(50., 100.)).into())
transform: Transform::from_translation(Vec3::new(-100., 0., 0.)), .into(),
material: materials.add(ColorMaterial::from(Color::LIME_GREEN)),
transform: Transform::from_translation(Vec3::new(50., 0., 0.)),
..default() ..default()
}); });
@ -38,7 +49,7 @@ fn setup(
commands.spawn(MaterialMesh2dBundle { commands.spawn(MaterialMesh2dBundle {
mesh: meshes.add(shape::RegularPolygon::new(50., 6).into()).into(), mesh: meshes.add(shape::RegularPolygon::new(50., 6).into()).into(),
material: materials.add(ColorMaterial::from(Color::TURQUOISE)), material: materials.add(ColorMaterial::from(Color::TURQUOISE)),
transform: Transform::from_translation(Vec3::new(100., 0., 0.)), transform: Transform::from_translation(Vec3::new(150., 0., 0.)),
..default() ..default()
}); });
} }