From b450255081abd8d5775fbd6f884a0adf050bc6ab Mon Sep 17 00:00:00 2001 From: anig1scur Date: Mon, 19 Feb 2024 02:05:25 +0800 Subject: [PATCH] chore: draw_aimline if onpointerdown --- src/game.rs | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/game.rs b/src/game.rs index 55b8f1b..5394147 100644 --- a/src/game.rs +++ b/src/game.rs @@ -488,19 +488,6 @@ pub fn game(props: &Props) -> Html { Callback::from(move |h| mh.set(h)) }; - // 瞄准 - let start_aimline = { - clone_all![is_draw_aimline, is_moving, is_game_over]; - Callback::from(move |_| { - if !*is_moving && !*is_game_over { - *is_draw_aimline.borrow_mut() = true; - } - }) - }; - let cancel_aimline = { - clone_all![is_draw_aimline]; - Callback::from(move |_| *is_draw_aimline.borrow_mut() = false) - }; let draw_aimline = { clone_all![is_draw_aimline, canvas_ref, map_status]; Callback::from(move |event: PointerEvent| { @@ -534,6 +521,22 @@ pub fn game(props: &Props) -> Html { }) }; + // 瞄准 + let start_aimline = { + clone_all![is_draw_aimline, is_moving, is_game_over, draw_aimline]; + Callback::from(move |e| { + if !*is_moving && !*is_game_over { + *is_draw_aimline.borrow_mut() = true; + draw_aimline.emit(e); + } + }) + }; + + let cancel_aimline = { + clone_all![is_draw_aimline]; + Callback::from(move |_| *is_draw_aimline.borrow_mut() = false) + }; + // 点击 let onclick = { clone_all![