Skip to content

Commit

Permalink
chore: draw_aimline if onpointerdown
Browse files Browse the repository at this point in the history
  • Loading branch information
anig1scur committed Feb 18, 2024
1 parent 0182cc3 commit b450255
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions src/game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand Down Expand Up @@ -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![
Expand Down

0 comments on commit b450255

Please sign in to comment.