Multiple dice, but text below mesh...

main
Elijah C. Voigt 1 year ago
parent 2d03309c4c
commit 57e8caa1b7

@ -72,15 +72,24 @@ fn init_dice(
mut materials: ResMut<Assets<ColorMaterial>>, mut materials: ResMut<Assets<ColorMaterial>>,
mut commands: Commands mut commands: Commands
) { ) {
[
["a", "b", "c", "d", "e", "f"],
["g", "h", "i", "j", "k", "l"],
["m", "n", "o", "p", "q", "r"],
].into_iter().enumerate().for_each(|(idx, set)| {
commands.spawn(( commands.spawn((
GameChoice::Dice, MenuState::Closed, GameChoice::Dice, MenuState::Closed,
Die::new(["a", "b", "c", "d", "e", "f"]), Die::new(set),
PickableBundle { ..default() }, PickableBundle { ..default() },
On::<Pointer<Drag>>::target_component_mut::<Transform>(|m, transform| { On::<Pointer<Drag>>::target_component_mut::<Transform>(|m, transform| {
transform.translation.x += m.delta.x; transform.translation.x += m.delta.x;
transform.translation.y -= m.delta.y; transform.translation.y -= m.delta.y;
}) })
)).insert(Text2dBundle { )).insert(MaterialMesh2dBundle {
mesh: meshes.add(Rectangle { half_size: Vec2::splat(32.0) }).into(),
material: materials.add(Color::PINK),
..default()
}).insert(Text2dBundle {
text: Text::from_section( text: Text::from_section(
"", "",
TextStyle { TextStyle {
@ -90,10 +99,7 @@ fn init_dice(
}, },
), ),
..default() ..default()
}).insert(MaterialMesh2dBundle { }).insert(Transform::from_xyz(idx as f32 * 100.0, 100.0, 0.0));
mesh: meshes.add(Rectangle { half_size: Vec2::splat(32.0) }).into(),
material: materials.add(Color::PINK),
..default()
}); });
} }

Loading…
Cancel
Save