Multiple dice, but text below mesh...

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

@ -72,28 +72,34 @@ fn init_dice(
mut materials: ResMut<Assets<ColorMaterial>>,
mut commands: Commands
) {
commands.spawn((
GameChoice::Dice, MenuState::Closed,
Die::new(["a", "b", "c", "d", "e", "f"]),
PickableBundle { ..default() },
On::<Pointer<Drag>>::target_component_mut::<Transform>(|m, transform| {
transform.translation.x += m.delta.x;
transform.translation.y -= m.delta.y;
})
)).insert(Text2dBundle {
text: Text::from_section(
"",
TextStyle {
color: Color::BLACK,
font_size: 32.0,
..default()
},
),
..default()
}).insert(MaterialMesh2dBundle {
mesh: meshes.add(Rectangle { half_size: Vec2::splat(32.0) }).into(),
material: materials.add(Color::PINK),
..default()
[
["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((
GameChoice::Dice, MenuState::Closed,
Die::new(set),
PickableBundle { ..default() },
On::<Pointer<Drag>>::target_component_mut::<Transform>(|m, transform| {
transform.translation.x += m.delta.x;
transform.translation.y -= m.delta.y;
})
)).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(
"",
TextStyle {
color: Color::BLACK,
font_size: 32.0,
..default()
},
),
..default()
}).insert(Transform::from_xyz(idx as f32 * 100.0, 100.0, 0.0));
});
}

Loading…
Cancel
Save