Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Drag and drop input
- var lh_selected = false
- var rh_selected = false
- func lh_movement():
- if lh_selected == true:
- $Table/Player/LeftHand.position = get_global_mouse_position()
- else:
- $Table/Player/LeftHand.position = $Table/Player/LeftHand/OriginalPos.position
- func rh_movement():
- if rh_selected == true:
- $Table/Player/RightHand.position = get_global_mouse_position()
- else:
- $Table/Player/RightHand.position = $Table/Player/RightHand/OriginalPos.position
- func _on_playerlh_area_2d_input_event(viewport, event, shape_idx):
- if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT:
- if event.pressed:
- # Mouse clicked
- lh_selected = true
- else:
- # Mouse released
- lh_selected = false
- func _on_playerrh_area_2d_input_event(viewport, event, shape_idx):
- if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT:
- if event.pressed:
- # Mouse clicked
- rh_selected = true
- else:
- # Mouse released
- rh_selected = false
- # --------------------------------------------------------------------------------------------------------------------
- # Finger adding
- var oppo_rh = 1
- var oppo_lh = 1
- var play_rh = 1
- var play_lh = 1
- func _on_opponent_rh_area_2d_area_entered(area):
- var touched_hand = area.get_parent()
- if touched_hand.get_name() == "LeftHand" and touched_hand.get_parent().get_name() == "Player":
- oppo_rh += play_lh
- elif touched_hand.get_name() == "RightHand" and touched_hand.get_parent().get_name() == "Player":
- oppo_rh += play_rh
- elif touched_hand.get_name() == "LeftHand" and touched_hand.get_parent().get_name() == "Opponent":
- oppo_rh += oppo_lh
- elif touched_hand.get_name() == "RightHand" and touched_hand.get_parent().get_name() == "Opponent":
- oppo_rh += oppo_rh
- else:
- print("Error.")
- func _on_player_lh_area_2d_area_entered(area):
- var touched_hand = area.get_parent()
- if touched_hand.get_name() == "LeftHand" and touched_hand.get_parent().get_name() == "Player":
- play_lh += play_lh
- elif touched_hand.get_name() == "RightHand" and touched_hand.get_parent().get_name() == "Player":
- play_lh += play_rh
- elif touched_hand.get_name() == "LeftHand" and touched_hand.get_parent().get_name() == "Opponent":
- play_lh += oppo_lh
- elif touched_hand.get_name() == "RightHand" and touched_hand.get_parent().get_name() == "Opponent":
- play_lh += oppo_rh
- else:
- print("Error.")
- func _on_player_rh_area_2d_area_entered(area):
- var touched_hand = area.get_parent()
- if touched_hand.get_name() == "LeftHand" and touched_hand.get_parent().get_name() == "Player":
- play_rh += play_lh
- elif touched_hand.get_name() == "RightHand" and touched_hand.get_parent().get_name() == "Player":
- play_rh += play_rh
- elif touched_hand.get_name() == "LeftHand" and touched_hand.get_parent().get_name() == "Opponent":
- play_rh += oppo_lh
- elif touched_hand.get_name() == "RightHand" and touched_hand.get_parent().get_name() == "Opponent":
- play_rh += oppo_rh
- else:
- print("Error.")
Advertisement
Add Comment
Please, Sign In to add comment