Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions examples/2d/sprite_slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,24 +83,22 @@ fn spawn_sprites(

for (label, text_style, size, scale_mode) in cases {
position.x += 0.5 * size.x;
let mut cmd = commands.spawn((
commands.spawn((
Sprite {
image: texture_handle.clone(),
custom_size: Some(size),
image_mode: scale_mode,
..default()
},
Transform::from_translation(position),
));
cmd.with_children(|builder| {
builder.spawn((
children![(
Text2d::new(label),
text_style,
TextLayout::new_with_justify(JustifyText::Center),
Transform::from_xyz(0., -0.5 * size.y - 10., 0.0),
bevy::sprite::Anchor::TopCenter,
));
});
)],
));
position.x += 0.5 * size.x + gap;
}
}
Expand Down
24 changes: 11 additions & 13 deletions examples/audio/spatial_audio_2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,23 @@ fn setup(
));

let listener = SpatialListener::new(gap);
commands
.spawn((
Transform::default(),
Visibility::default(),
listener.clone(),
))
.with_children(|parent| {
commands.spawn((
Transform::default(),
Visibility::default(),
listener.clone(),
children![
// left ear
parent.spawn((
(
Sprite::from_color(RED, Vec2::splat(20.0)),
Transform::from_xyz(-gap / 2.0, 0.0, 0.0),
));

),
// right ear
parent.spawn((
(
Sprite::from_color(LIME, Vec2::splat(20.0)),
Transform::from_xyz(gap / 2.0, 0.0, 0.0),
));
});
)
],
));

// example instructions
commands.spawn((
Expand Down
24 changes: 11 additions & 13 deletions examples/audio/spatial_audio_3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,25 @@ fn setup(
));

let listener = SpatialListener::new(gap);
commands
.spawn((
Transform::default(),
Visibility::default(),
listener.clone(),
))
.with_children(|parent| {
commands.spawn((
Transform::default(),
Visibility::default(),
listener.clone(),
children![
// left ear indicator
parent.spawn((
(
Mesh3d(meshes.add(Cuboid::new(0.2, 0.2, 0.2))),
MeshMaterial3d(materials.add(Color::from(RED))),
Transform::from_translation(listener.left_ear_offset),
));

),
// right ear indicator
parent.spawn((
(
Mesh3d(meshes.add(Cuboid::new(0.2, 0.2, 0.2))),
MeshMaterial3d(materials.add(Color::from(LIME))),
Transform::from_translation(listener.right_ear_offset),
));
});
)
],
));

// light
commands.spawn((
Expand Down