1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-18 17:19:50 +00:00
Pixelorama/Scripts/CameraMovement.gd
OverloadedOrama 5781c42821 v0.2 - Animation Timeline & UI changes!
v0.2 of Pixelorama is out!
- Added animation timeline. You can add. remove. clone and change order of your frames!
- You can now import multiple images as frames.
- Ability to save individual frames, all frames as multiple files, or all frames as a single file in the form of a horizontal or vertical spritesheet!
- Different frames can have a unique amount of layers and they can be of different sizes.
- Image scaling is now functional.
- Added hints for UI elements.
- A lot of UI changes.
2019-09-10 01:57:46 +03:00

31 lines
876 B
GDScript

extends Camera2D
var zoom_min := Vector2(0.005, 0.005)
var zoom_max := Vector2.ONE
var drag := false
func _input(event) -> void:
if Global.can_draw && Global.has_focus:
if event.is_action_pressed("camera_drag"):
drag = true
elif event.is_action_released("camera_drag"):
drag = false
elif event.is_action_pressed("zoom_in"): # Wheel Up Event
zoom_camera(-1)
elif event.is_action_pressed("zoom_out"): # Wheel Down Event
zoom_camera(1)
elif event is InputEventMouseMotion && drag:
offset = offset - event.relative * zoom
# Zoom Camera
func zoom_camera(dir : int) -> void:
var zoom_margin = zoom * dir / 10
#if zoom + zoom_margin > zoom_min && zoom + zoom_margin < zoom_max:
if zoom + zoom_margin > zoom_min:
zoom += zoom_margin
if zoom > zoom_max:
zoom = zoom_max
Global.zoom_level_label.text = "Zoom: x%s" % [stepify(1 / zoom.x, 0.01)]