daily pastebin goal
82%
SHARE
TWEET

Untitled

a guest Sep 14th, 2018 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. func _input(event):
  2.     if self.mouse_in_grid && !mouse_has_entered:
  3.         emit_signal("mouse_entered")
  4.     if !self.mouse_in_grid && mouse_has_entered:
  5.         emit_signal("mouse_exited")
  6.  
  7.     if should_ignore_mouse || !self.mouse_in_grid:
  8.         return
  9.  
  10.     if event is InputEventMouseButton:
  11.         var normalizedX = floor(event.position.x / cellSize.x)
  12.         var normalizedY = floor(event.position.y / cellSize.y)
  13.         mouse_left_is_pressed = event.pressed && event.button_index == BUTTON_LEFT #set the mouse pressed bool
  14.         if event.pressed && event.button_index == BUTTON_LEFT:
  15.             emit_signal("mouse_left_clicked", Vector2(normalizedX, normalizedY))
  16.         elif event.pressed && event.button_index == BUTTON_RIGHT:
  17.             emit_signal("mouse_right_clicked", Vector2(normalizedX, normalizedY), true)
  18.        
  19.     elif event is InputEventMouseMotion:
  20.         if event.position.x >= 0 && event.position.x < (drawSize.x):
  21.             if event.position.y >= 0 && event.position.y < drawSize.y:
  22.                 var mousePosition = get_local_mouse_position()
  23.                 if mouse_left_is_pressed:
  24.                     print("dragged")
  25.                     emit_signal("mouse_left_dragged", Vector2(normalizedX, normalizedY), false)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top