Skip to main content

input_touch/
input_touch.rs

1use macroquad::prelude::*;
2
3#[macroquad::main("InputTouch")]
4async fn main() {
5    loop {
6        clear_background(LIGHTGRAY);
7
8        for touch in touches() {
9            let (fill_color, size) = match touch.phase {
10                TouchPhase::Started => (GREEN, 80.0),
11                TouchPhase::Stationary => (WHITE, 60.0),
12                TouchPhase::Moved => (YELLOW, 60.0),
13                TouchPhase::Ended => (BLUE, 80.0),
14                TouchPhase::Cancelled => (BLACK, 80.0),
15            };
16            draw_circle(touch.position.x, touch.position.y, size, fill_color);
17        }
18
19        draw_text("touch the screen!", 20.0, 20.0, 20.0, DARKGRAY);
20        next_frame().await
21    }
22}