circles punch: touchscreen support

This commit is contained in:
djmil 2024-08-31 20:49:23 +02:00
parent 292dfb8ee3
commit 92ceea208f

View File

@ -21,8 +21,8 @@ pub struct Simulation {
impl Default for Simulation {
fn default() -> Self {
Self {
circles: Vec::new(),
circles_count: 2,
circles: Vec::new(),
colors: Vec::new(),
}
}
@ -122,10 +122,11 @@ impl eframe::App for Simulation {
);
}
let (hover_pos, any_down, any_released) = ctx.input(|input| (
let (hover_pos, any_down, any_released, any_pressed) = ctx.input(|input| (
input.pointer.hover_pos(),
input.pointer.any_down(),
input.pointer.any_released()
input.pointer.any_released(),
input.pointer.any_pressed()
));
if let Some(mousepos) = hover_pos {
@ -138,7 +139,7 @@ impl eframe::App for Simulation {
Stroke{width: 1.5, color: Color32::from_rgb(255, 0, 0)});
}
if any_released {
if any_released || any_pressed {
circle.v += d.normalized() * (d.length() / circle.r) * 8.0;
}
}