Advertisement
otorp2

camera zoom place on root node

Mar 14th, 2016
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1.  
  2. extends Node2D
  3.  
  4. # member variables here, example:
  5. # var a=2
  6. # var b="textvar"
  7.  
  8. func _ready():
  9. set_process_input(true)
  10. pass
  11. func _input(event):
  12. if(event.is_pressed()):
  13. if(Input.is_key_pressed(KEY_ESCAPE)):
  14. get_tree().quit()
  15.  
  16. var zoom = get_node("camera").get_zoom()
  17.  
  18. if (event.type == InputEvent.MOUSE_BUTTON):
  19. if (event.button_index == BUTTON_WHEEL_UP):
  20. print("wheel up (event)")
  21. zoom[0] = zoom[0] + 1
  22. zoom[1] = zoom[1] + 1
  23. if (event.button_index == BUTTON_WHEEL_DOWN):
  24. print("wheel down (event)")
  25. zoom[0] = zoom[0] - 1
  26. zoom[1] = zoom[1] - 1
  27.  
  28. get_node("camera").set_zoom(zoom)
  29.  
  30. print (zoom)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement